Skip to content

chore(actions): allow forcing snapshots deployment #261

chore(actions): allow forcing snapshots deployment

chore(actions): allow forcing snapshots deployment #261

Workflow file for this run

name: vertx-vaadin validation
on:
push:
branches: [development, vaadin-24.4, vaadin-23]
workflow_dispatch:
inputs:
force-deploy:
description: "Force snapshot deploy"
default: false
required: false
type: boolean
pull_request_target:
types: [opened, synchronize, reopened, edited]
permissions:
contents: read
concurrency:
group: ${{ github.head_ref || github.ref_name }}
cancel-in-progress: true
env:
JAVA_VERSION: 17
jobs:
check-permissions:
name: Check User Permissions
runs-on: ubuntu-latest
steps:
- run: echo "Concurrency Group = ${{ github.head_ref || github.ref_name }}"
- uses: actions-cool/check-user-permission@main
id: checkUser
with:
username: ${{github.triggering_actor}}
require: 'write'
- name: Fail on workflow triggered by external contributor
if: ${{ steps.checkUser.outputs.require-result != 'true' && github.actor != 'dependabot[bot]' && github.actor != 'vertx-vaadin-bot[bot]' }}
run: |
echo "🚫 **${{ github.actor }}** is an external contributor, a **${{ github.repository }}** team member has to review this changes and re-run this build" \
| tee -a $GITHUB_STEP_SUMMARY && exit 1
changes:
name: Compute changes
needs: [check-permissions]
runs-on: ubuntu-latest
outputs:
validation-required: ${{ steps.filter.outputs.validate }}
deploy-required: ${{ steps.filter.outputs.deploy }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
validate:
- '!(README.md|LICENSE|.gitignore|tools/**)'
deploy:
- 'pom.xml'
- 'vertx-vaadin-flow/pom.xml'
- 'vertx-vaadin-flow/src/**'
- 'vaadin-flow-sockjs/pom.xml'
- 'vaadin-flow-sockjs/src/**'
- 'vertx-vaadin-flow-jandex/pom.xml'
- 'vertx-vaadin-quarkus-extension/pom.xml'
- 'vertx-vaadin-quarkus-extension/runtime/pom.xml'
- 'vertx-vaadin-quarkus-extension/runtime/src/**'
- 'vertx-vaadin-quarkus-extension/deployment/pom.xml'
- 'vertx-vaadin-quarkus-extension/deployment/src/**'
build:
name: Build
needs: [changes]
if: ${{ needs.changes.outputs.validation-required == 'true' }}
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: 'temurin'
cache: maven
- uses: browser-actions/setup-chrome@latest
id: setup-chrome
if: ${{ !vars.QH_DISABLE_CHROME_INSTALL }}
with:
chrome-version: stable
- name: Build
env:
VAADIN_PRO_KEY: ${{ secrets.VAADIN_PRO_KEY }}
run: |
set -x -e -o pipefail
VERTX_VAADIN_VERSION=$(mvn -N -ntp -q help:evaluate -Dexpression=project.version -DforceStdout)
echo "VERTX_VAADIN_VERSION=${VERTX_VAADIN_VERSION}" >> "$GITHUB_ENV"
mvn -V -e -B -ntp -DskipTests -DskipVertxRun=true install -Pflow-ui-tests
- name: Save workspace
run: |
tar cf workspace.tar -C ~/ $(cd ~/ && echo .m2/repository/com/github/mcollovati/vertx/**/$VERTX_VAADIN_VERSION)
tar rf workspace.tar $(find . -d -name target)
- uses: actions/upload-artifact@v4
with:
name: saved-workspace
path: workspace.tar
tests:
name: Tests
needs: [build]
if: ${{needs.changes.outputs.validation-required == 'true'}}
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: 'temurin'
cache: maven
- uses: browser-actions/setup-chrome@latest
id: setup-chrome
if: ${{ !vars.QH_DISABLE_CHROME_INSTALL }}
with:
chrome-version: stable
- uses: actions/download-artifact@v4
if: ${{ github.run_attempt == 1 }}
with:
name: saved-workspace
- name: Restore Workspace
if: ${{ github.run_attempt == 1 }}
run: |
set -x
tar xf workspace.tar
tar cf - .m2 | (cd ~ && tar xf -)
- name: Build
if: ${{ github.run_attempt > 1 }}
env:
VAADIN_PRO_KEY: ${{ secrets.VAADIN_PRO_KEY }}
run: |
set -x -e -o pipefail
mvn -V -e -B -ntp -DskipTests -DskipVertxRun=true -Dmaven.javadoc.skip=false install -Pflow-ui-tests
- name: Test
env:
VAADIN_PRO_KEY: ${{ secrets.VAADIN_PRO_KEY }}
run: |
set -x -e -o pipefail
mvn -V -e -B -ntp verify -Dmaven.javadoc.skip=false -DtrimStackTrace=false
- name: Package test output files
if: ${{ failure() || success() }}
run: find . -name surefire-reports -o -name failsafe-reports | tar -czf tests-report-main.tgz -T -
- uses: actions/upload-artifact@v4
if: ${{ failure() || success() }}
with:
name: tests-output-ut-1
path: tests-report-*.tgz
it-tests-1:
name: UI tests 1
needs: [build]
if: ${{needs.changes.outputs.validation-required == 'true'}}
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: 'temurin'
cache: maven
- uses: browser-actions/setup-chrome@latest
id: setup-chrome
if: ${{ !vars.QH_DISABLE_CHROME_INSTALL }}
with:
chrome-version: stable
- name: Set Chrome Version
run: |
CHROME_VERSION=$(google-chrome --version | sed 's/^Google Chrome //' | cut -d. -f1)
echo "CHROME_VERSION=${CHROME_VERSION}" >> "$GITHUB_ENV"
- uses: actions/download-artifact@v4
if: ${{ github.run_attempt == 1 }}
with:
name: saved-workspace
- name: Restore Workspace
if: ${{ github.run_attempt == 1 }}
run: |
set -x
tar xf workspace.tar
tar cf - .m2 | (cd ~ && tar xf -)
- name: Build
if: ${{ github.run_attempt > 1 }}
env:
VAADIN_PRO_KEY: ${{ secrets.VAADIN_PRO_KEY }}
run: |
set -x -e -o pipefail
mvn -V -e -B -ntp -DskipTests -DskipVertxRun=true -Dmaven.javadoc.skip=false install -Pflow-ui-tests
- name: UI Test
env:
VAADIN_PRO_KEY: ${{ secrets.VAADIN_PRO_KEY }}
run: |
set -x -e -o pipefail
cd vertx-vaadin-tests
rm -rf frontend/generated
mvn -V -e -B -ntp verify -Dmaven.javadoc.skip=false -pl=:vertx-vaadin-test-root-context -DtrimStackTrace=false \
-Dwebdriver.chrome.driver=$(which chromedriver) \
-Duitest.chrome-version=$CHROME_VERSION
- name: Package test output files
if: ${{ failure() || success() }}
run: find . -name surefire-reports -o -name failsafe-reports -o -name error-screenshots -o -name verticle.log | tar -czf tests-report-it-1.tgz -T -
- uses: actions/upload-artifact@v4
if: ${{ failure() || success() }}
with:
name: tests-output-it-1
path: tests-report-*.tgz
it-tests-2:
name: UI tests 2
needs: [build]
if: ${{needs.changes.outputs.validation-required == 'true' }}
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: 'temurin'
cache: maven
- uses: browser-actions/setup-chrome@latest
id: setup-chrome
if: ${{ !vars.QH_DISABLE_CHROME_INSTALL }}
with:
chrome-version: stable
- uses: actions/download-artifact@v4
if: ${{ github.run_attempt == 1 }}
with:
name: saved-workspace
- name: Restore Workspace
if: ${{ github.run_attempt == 1 }}
run: |
set -x
tar xf workspace.tar
tar cf - .m2 | (cd ~ && tar xf -)
- name: Build
if: ${{ github.run_attempt > 1 }}
run: |
set -x -e -o pipefail
mvn -V -e -B -ntp -DskipTests -Dmaven.javadoc.skip=false install -Pflow-ui-tests
- name: UI Test
env:
VAADIN_PRO_KEY: ${{ secrets.VAADIN_PRO_KEY }}
run: |
set -x -e -o pipefail
cd vertx-vaadin-tests/
mvn -V -e -B -ntp verify -DtrimStackTrace=false -pl=-:vertx-vaadin-test-root-context -Dwebdriver.chrome.driver=$(which chromedriver)
- name: Package test output files
if: ${{ failure() || success() }}
run: find . -name surefire-reports -o -name failsafe-reports -o -name error-screenshots -o -name verticle.log | tar -czf tests-report-it-2.tgz -T -
- uses: actions/upload-artifact@v4
if: ${{ failure() || success() }}
with:
name: tests-output-it-2
path: tests-report-*.tgz
test-results:
permissions:
issues: read
checks: write
pull-requests: write
if: ${{ always() }}
needs: [changes, tests, it-tests-1, it-tests-2]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/download-artifact@v4
if: ${{ always() && needs.changes.outputs.validation-required == 'true' }}
with:
pattern: tests-output-*
merge-multiple: true
- name: Extract downloaded files
if: ${{ always() && needs.changes.outputs.validation-required == 'true' }}
run: for i in *.tgz; do tar xvf $i; done
- name: Publish Unit Test Results
if: ${{ always() && needs.changes.outputs.validation-required == 'true' }}
uses: EnricoMi/publish-unit-test-result-action@v2
with:
junit_files: "**/target/*-reports/TEST*.xml"
- name: Set Failure Status
if: ${{ always() && needs.changes.outputs.validation-required == 'true' && (needs.tests.result != 'success' || needs.it-tests-1.result != 'success' || needs.it-tests-2.result != 'success') }}
run: |
echo "🚫 THERE ARE TEST MODULES WITH FAILURES or BEEN CANCELLED" | tee -a $GITHUB_STEP_SUMMARY
exit 1
- name: Set validation skipped status
if: ${{ always() && needs.changes.outputs.validation-required == 'false' }}
run: |
echo "✅ Pull request only contains changes on files ignored by validation workflow" | tee -a $GITHUB_STEP_SUMMARY && exit 0
deploy-snapshots:
runs-on: ubuntu-latest
needs: [test-results]
permissions:
contents: read
packages: write
if: ${{ success() && github.ref_protected && ((github.event_name == 'push' && needs.changes.outputs.deploy-required == 'true') || (github.event_name == 'workflow_dispatch' && github.event.inputs.force-deploy == 'true'))}}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: ${{ env.JAVA_VERSION }}
server-id: repsy-vertx-vaadin-snapshots
server-username: REPSY_USERNAME
server-password: REPSY_PASSWORD
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- uses: actions/download-artifact@v4
if: ${{ github.run_attempt == 1 }}
with:
name: saved-workspace
- name: Restore Workspace
if: ${{ github.run_attempt == 1 }}
run: |
set -x
tar xf workspace.tar
tar cf - .m2 | (cd ~ && tar xf -)
- name: Build
if: ${{ github.run_attempt > 1 }}
run: |
set -x -e -o pipefail
mvn -V -e -B -ntp -DskipTests install
- name: Deploy artifacts
run: |
mvn -V -e -B -ntp -DskipVertxRun=true -DskipTests -Dvertx-vaadin.release=snapshot -Dvertx-vaadin.release.gpg deploy
env:
VAADIN_PRO_KEY: ${{ secrets.VAADIN_PRO_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPSY_USERNAME: ${{ secrets.REPSY_USERNAME }}
REPSY_PASSWORD: ${{ secrets.REPSY_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}