Backport of the rest UI fixes missing in the 1.2 #1674
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: E2E Test | |
on: | |
pull_request_target: | |
branches: | |
- 1.2.x | |
paths-ignore: | |
- '**.md' | |
types: | |
- opened | |
- synchronize | |
- reopened | |
- edited | |
push: | |
branches: | |
- 1.2.x | |
paths-ignore: | |
- '**.md' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
env: | |
HAWTIO_BRANCH: 4.x | |
jobs: | |
test: | |
permissions: | |
pull-requests: read | |
strategy: | |
fail-fast: false | |
matrix: | |
node: ['18', '20'] | |
java: ['17', '21'] | |
runtime: ['springboot', 'quarkus'] | |
browser: ['firefox'] # 'chrome' tests are unstable: https://github.com/hawtio/hawtio-next/issues/478 | |
env: | |
REPORT_DIR: results-${{matrix.runtime}}-node(${{matrix.node}})-java(${{matrix.java}})-${{matrix.browser}} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
if: ${{ github.event_name == 'pull_request_target' }} | |
with: | |
ref: 'refs/pull/${{ github.event.number }}/merge' | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
if: ${{ github.event_name == 'push' }} | |
- name: Docker Setup QEMU | |
uses: docker/[email protected] | |
- name: Set up Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node }} | |
- name: Get yarn cache directory path | |
id: yarn-cache-dir-path | |
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT | |
- uses: actions/cache@v4 | |
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn- | |
- name: Install | |
run: yarn install | |
- name: Build | |
run: yarn build:all | |
- name: Start server | |
run: | | |
yarn start:app --no-color --no-hot --no-live-reload --no-client-overlay > log & | |
# Check both CRACO and Webpack log messages until we migrate to Webpack | |
# https://github.com/hawtio/hawtio-next/pull/847 | |
timeout 30 bash -c "while ! grep -e 'You can now view app in the browser.' -e 'webpack .\+ compiled successfully' log ; do cat log; sleep 5; done" | |
- name: Detect testsuite branch | |
id: get-images | |
env: | |
body: ${{ github.event.pull_request.body || ''}} | |
run: | | |
if [[ "${body}" =~ \`branch:[[:space:]]([[:alnum:]\/_.-]+)(:([[:alnum:]\/_.-]+))?\` ]]; then | |
if [ -z "${BASH_REMATCH[2]}" ]; then | |
echo "repo=hawtio/hawtio" >> $GITHUB_OUTPUT | |
echo "branch=${BASH_REMATCH[1]}" >> $GITHUB_OUTPUT | |
else | |
echo "repo=${BASH_REMATCH[1]}/hawtio" >> $GITHUB_OUTPUT | |
echo "branch=${BASH_REMATCH[2]:1}" >> $GITHUB_OUTPUT | |
fi | |
else | |
branch=${{env.HAWTIO_BRANCH}} | |
app_image=quay.io/hawtio/hawtio-${{ matrix.runtime }}-test-app:$branch-${{ matrix.java }} | |
testsuite_image=quay.io/hawtio/hawtio-test-suite:$branch-${{ matrix.java }} | |
docker pull $app_image | |
docker pull $testsuite_image | |
echo "app-image=$app_image" >> $GITHUB_ENV | |
echo "testsuite-image=$testsuite_image" >> $GITHUB_ENV | |
fi | |
- name: Checkout Hawtio | |
if: ${{ steps.get-images.outputs.repo != ''}} | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ steps.get-images.outputs.repo }} | |
ref: ${{ steps.get-images.outputs.branch }} | |
path: hawtio | |
- name: Set up Java | |
if: ${{ steps.get-images.outputs.repo != ''}} | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: ${{matrix.java}} | |
cache: 'maven' | |
- name: Build Hawtio | |
if: ${{ steps.get-images.outputs.repo != ''}} | |
run: | | |
cd hawtio | |
mvn --batch-mode --no-transfer-progress install -DskipTests -Pe2e -Pdocker-testsuite -Ptests-docker -Dhawtio-container -pl :hawtio-test-suite,:hawtio-tests-quarkus,:hawtio-tests-springboot -am | |
echo 'app-image=hawtio-${{ matrix.runtime }}-app:${{ matrix.java }}' >> $GITHUB_ENV | |
echo 'testsuite-image=hawtio-test-suite:${{ matrix.java }}' >> $GITHUB_ENV | |
- name: Setup application | |
run: | | |
case ${{ matrix.runtime }} in | |
quarkus) | |
APP_PORT=8080 | |
echo "url-suffix=hawtio" >> $GITHUB_ENV | |
echo 'app-port=8080' >> $GITHUB_ENV | |
;; | |
springboot) | |
APP_PORT=10001 | |
echo "url-suffix=actuator/hawtio" >> $GITHUB_ENV | |
echo 'app-port=10001' >> $GITHUB_ENV | |
;; | |
esac | |
id=$(docker run --name app --network host -d ${{ env.app-image }}) | |
timeout 30 bash -c "while ! docker logs $id 2>&1 | grep -q 'Hello Camel!'; do sleep 1; done" | |
- name: Run tests | |
run: | | |
mkdir -p $PWD/$REPORT_DIR/ | |
docker run --rm --network host \ | |
-v $PWD/$REPORT_DIR:/hawtio-test-suite/tests/hawtio-test-suite/target \ | |
-v $PWD/$REPORT_DIR/build:/hawtio-test-suite/tests/hawtio-test-suite/build/ \ | |
--shm-size="2g" \ | |
${{ env.testsuite-image }} -Pe2e-${{ matrix.runtime }} -Dselenide.browser=${{ matrix.browser }} \ | |
-Dio.hawt.test.url=http://localhost:3000/hawtio \ | |
-Dio.hawt.test.app.connect.url=http://localhost:${{ env.app-port }}/${{ env.url-suffix }}/jolokia \ | |
-Dhawtio-next-ci | |
- name: Prepare report artifacts | |
if: always() | |
run: | | |
mkdir -p results/$REPORT_DIR/ | |
cp $REPORT_DIR/cucumber-reports/* results/$REPORT_DIR/ | |
docker logs app 2>&1 > results/$REPORT_DIR/container.log | |
docker logs app 2>&1 > $REPORT_DIR/container.log | |
echo "Container log:" | |
cat results/$REPORT_DIR/container.log | |
- name: Archive test artifacts | |
uses: actions/upload-artifact@v3 | |
if: always() | |
with: | |
name: 'test-${{ env.REPORT_DIR }}' | |
path: | | |
${{ env.REPORT_DIR }}/build/reports/tests/*.png | |
${{ env.REPORT_DIR }}/*.log | |
${{ env.REPORT_DIR }}/cucumber-reports/* | |
- name: Archive failed test reports | |
uses: actions/upload-artifact@v3 | |
if: always() | |
with: | |
name: 'test-results' | |
path: | | |
results/**/* | |
publish-results: | |
runs-on: ubuntu-latest | |
needs: test | |
if: always() | |
permissions: | |
checks: write | |
actions: read | |
pull-requests: write | |
steps: | |
- name: Download Test Results | |
uses: actions/download-artifact@v3 | |
with: | |
name: 'test-results' | |
path: 'test-results' | |
- name: Publish Test Results | |
uses: EnricoMi/publish-unit-test-result-action@v2 | |
if: always() | |
with: | |
files: | | |
**/Cucumber.xml | |
json_file: results.json | |
- name: Install xmllint | |
run: sudo apt-get install -y xmlstarlet jq | |
- name: Generate summary | |
run: | | |
export CHECK_URL=$(jq -r .check_url results.json) | |
wget https://raw.githubusercontent.com/hawtio/hawtio/${{ env.HAWTIO_BRANCH }}/tests/hawtio-test-suite/process_test_results.sh | |
wget https://raw.githubusercontent.com/hawtio/hawtio/${{ env.HAWTIO_BRANCH }}/tests/hawtio-test-suite/pr_results_template.xsl | |
bash process_test_results.sh test-results > summary.md | |
- name: Update summary | |
run: | | |
cat summary.md >> $GITHUB_STEP_SUMMARY | |
- uses: tibdex/github-app-token@v2 | |
if: github.event_name == 'pull_request_target' | |
id: generate-token | |
with: | |
app_id: ${{ secrets.HAWTIO_CI_APP_ID }} | |
private_key: ${{ secrets.HAWTIO_CI_PRIVATE_KEY }} | |
- name: Comment PR with summary | |
if: github.event_name == 'pull_request_target' | |
uses: thollander/actions-comment-pull-request@v2 | |
with: | |
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} | |
filePath: summary.md | |
comment_tag: execution |