Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# The Docker build runs the Maven build from scratch, so it doesn't need
# local build output, dependencies, or IDE files
target/
node_modules/
.git
.idea/
.vscode/
.settings
.project
.classpath
*.iml
.DS_Store
420 changes: 420 additions & 0 deletions .github/steps/GenerateSteps.java

Large diffs are not rendered by default.

56 changes: 56 additions & 0 deletions .github/steps/commit-steps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env bash
#
# Commits the steps that GenerateSteps.java generated as a chain of commits, one per step, and
# points the step/<page> branches at them. A step keeps its commit if its files and the commit of
# the previous step are unchanged, so only the steps that changed, and the steps after them, get
# new commits.
#
# Usage: commit-steps.sh <output-dir> [--push]
#
# Run it in a clone of vaadin/tutorial. Without --push, it only prints which branches it would
# update. Set DOCS_COMMIT to the vaadin/docs commit that the steps were generated from, to mention
# it in the commit messages.

set -euo pipefail

steps=$1
push=${2:-}
remote=origin

git fetch --quiet "$remote" "+refs/heads/step/*:refs/remotes/$remote/step/*"

index=$(mktemp)
trap 'rm -f "$index"' EXIT

parent=
refspecs=()
while IFS=$'\t' read -r page title; do
branch=step/$page
rm -f "$index"
GIT_INDEX_FILE=$index git -c core.autocrlf=false --work-tree="$steps/$page" add --all
tree=$(GIT_INDEX_FILE=$index git write-tree)

commit=$(git rev-parse --quiet --verify "refs/remotes/$remote/$branch^{commit}" || true)
if [[ -n $commit && $(git rev-parse "$commit^{tree}") == "$tree" \
&& $(git rev-parse --quiet --verify "$commit^" || true) == "$parent" ]]; then
echo "$branch: unchanged"
else
message="The application of the Vaadin tutorial at the end of the $title step:"
message+=$'\n'"https://vaadin.com/docs/latest/getting-started/tutorial/$page"
if [[ -n ${DOCS_COMMIT:-} ]]; then
message+=$'\n\n'"Generated from vaadin/docs@$DOCS_COMMIT."
fi
commit=$(git commit-tree "$tree" ${parent:+-p "$parent"} -m "$title" -m "$message")
refspecs+=("+$commit:refs/heads/$branch")
echo "$branch: $commit"
fi
parent=$commit
done < "$steps/steps.tsv"

if [[ ${#refspecs[@]} -eq 0 ]]; then
echo "All step branches are up to date."
elif [[ $push == --push ]]; then
git push "$remote" "${refspecs[@]}"
else
echo "Not pushing. Run with --push to update the branches."
fi
144 changes: 144 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
name: CI

on:
push:
branches: [main]
pull_request:
schedule:
# Every Monday, to pick up changes to the tutorial
- cron: '0 4 * * 1'
workflow_dispatch:

env:
# The branch of vaadin/docs to generate the steps from. Use the branch of
# https://vaadin.com/docs/latest, so that the code matches the tutorial that
# most readers follow.
DOCS_REF: v25.3

permissions:
contents: read

jobs:
build:
name: Build main
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-java@v6
with:
distribution: temurin
java-version: 21
cache: maven
- run: ./mvnw -B -ntp verify

generate:
name: Generate steps
runs-on: ubuntu-latest
outputs:
steps: ${{ steps.generate.outputs.steps }}
docs-commit: ${{ steps.generate.outputs.docs-commit }}
steps:
- uses: actions/checkout@v7
- uses: actions/checkout@v7
with:
repository: vaadin/docs
ref: ${{ env.DOCS_REF }}
path: build/docs
sparse-checkout-cone-mode: false
sparse-checkout: |
/articles/_vaadin-version.adoc
/articles/getting-started/tutorial/
/src/main/resources/META-INF/resources/vaadin/tutorial/
- uses: actions/setup-java@v6
with:
distribution: temurin
java-version: 21
- name: Generate steps
id: generate
run: |
java .github/steps/GenerateSteps.java build/docs build/steps
echo "steps=$(cut -f1 build/steps/steps.tsv | jq -R . | jq -sc .)" >> "$GITHUB_OUTPUT"
echo "docs-commit=$(git -C build/docs rev-parse HEAD)" >> "$GITHUB_OUTPUT"
# The artifact would lose the executable bit of mvnw without the tar
- run: tar -cf build/steps.tar -C build steps
- uses: actions/upload-artifact@v7
with:
name: steps
path: build/steps.tar

check-main:
name: Check that main matches the last step
needs: generate
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/download-artifact@v8
with:
name: steps
path: build
- run: tar -xf build/steps.tar -C build
- name: Compare main with the last step
run: |
last=$(tail -n 1 build/steps/steps.tsv | cut -f1)
export GIT_INDEX_FILE=$RUNNER_TEMP/index
git -c core.autocrlf=false --work-tree="build/steps/$last" add --all
if ! git diff --cached --exit-code HEAD -- . ':!README.md' ':!.github'; then
echo "::error::main doesn't match the $last step of the tutorial. See Maintenance in README.md."
exit 1
fi
- name: Check that the README lists every step branch
run: |
status=0
while IFS=$'\t' read -r page title; do
if ! grep -q "step/$page" README.md; then
echo "::error::README.md doesn't mention the step/$page branch of the $title step."
status=1
fi
done < build/steps/steps.tsv
exit $status

verify:
name: Verify ${{ matrix.step }}
needs: generate
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
step: ${{ fromJSON(needs.generate.outputs.steps) }}
steps:
- uses: actions/download-artifact@v8
with:
name: steps
- run: tar -xf steps.tar
- uses: actions/setup-java@v6
with:
distribution: temurin
java-version: 21
cache: maven
cache-dependency-path: steps/${{ matrix.step }}/pom.xml
- run: ./mvnw -B -ntp verify
working-directory: steps/${{ matrix.step }}

publish:
name: Publish step branches
needs: [generate, verify]
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
concurrency: publish-steps
permissions:
contents: write
steps:
- uses: actions/checkout@v7
- uses: actions/download-artifact@v8
with:
name: steps
path: build
- run: tar -xf build/steps.tar -C build
- name: Commit and push the steps that changed
env:
GIT_AUTHOR_NAME: github-actions[bot]
GIT_AUTHOR_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com
GIT_COMMITTER_NAME: github-actions[bot]
GIT_COMMITTER_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com
DOCS_COMMIT: ${{ needs.generate.outputs.docs-commit }}
run: .github/steps/commit-steps.sh build/steps --push
29 changes: 10 additions & 19 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
target/

### Eclipse ###
.classpath
.project
/target/
.idea/
.vscode/
.settings
.project
.classpath

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
nbproject/private/
build/
nbbuild/
dist/
nbdist/
.nb-gradle/
.DS_Store

### JRebel ###
rebel.xml
# The following files are generated/updated by vaadin-maven-plugin
node_modules/
src/main/frontend/generated/
vite.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
wrapperVersion=3.3.2
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.12/apache-maven-3.9.12-bin.zip
42 changes: 42 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
FROM ghcr.io/jqlang/jq:latest AS jq-stage

FROM eclipse-temurin:21-jdk AS build
COPY --from=jq-stage /jq /usr/bin/jq
# Test that jq works after copying
RUN jq --version

ENV HOME=/app
RUN mkdir -p $HOME
WORKDIR $HOME
COPY . $HOME

# If you have a Vaadin Pro key, pass it as a secret with id "proKey":
#
# $ docker build --secret id=proKey,src=$HOME/.vaadin/proKey .
#
# If you have a Vaadin Offline key, pass it as a secret with id "offlineKey":
#
# $ docker build --secret id=offlineKey,src=$HOME/.vaadin/offlineKey .

RUN --mount=type=cache,target=/root/.m2 \
--mount=type=secret,id=proKey \
--mount=type=secret,id=offlineKey \
sh -c 'PRO_KEY=$(jq -r ".proKey // empty" /run/secrets/proKey 2>/dev/null || echo "") && \
OFFLINE_KEY=$(cat /run/secrets/offlineKey 2>/dev/null || echo "") && \
./mvnw clean package -DskipTests -Dvaadin.proKey=${PRO_KEY} -Dvaadin.offlineKey=${OFFLINE_KEY}'

# Split the JAR into layers, so that the dependencies get their own image layer
RUN cp target/*.jar application.jar && \
java -Djarmode=tools -jar application.jar extract --layers --destination extracted

FROM eclipse-temurin:21-jre-alpine
RUN addgroup -S app && adduser -S app -G app
USER app
WORKDIR /application
COPY --from=build /app/extracted/dependencies/ ./
COPY --from=build /app/extracted/spring-boot-loader/ ./
COPY --from=build /app/extracted/snapshot-dependencies/ ./
COPY --from=build /app/extracted/application/ ./
EXPOSE 8080
# Let the heap use 75% of the container's memory limit, instead of the default 25%
ENTRYPOINT ["java", "-XX:MaxRAMPercentage=75", "-jar", "application.jar", "--spring.profiles.active=prod"]
23 changes: 4 additions & 19 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@
This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to <http://unlicense.org>
For more information, please refer to http://unlicense.org
Loading
Loading