Build and Test #234
Workflow file for this run
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: Build and Test | |
on: | |
# run on PRs to main | |
pull_request: | |
branches: [ main ] | |
# run on push to main | |
push: | |
branches: [ main ] | |
# run when we create new releases | |
release: | |
types: [ published ] | |
# run manually | |
workflow_dispatch: | |
jobs: | |
build_and_test: | |
runs-on: ubuntu-latest | |
env: | |
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }} | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
steps: | |
- uses: actions/checkout@v3 | |
- run: bin/populate.sh | |
- name: Generate MASL | |
run: | | |
cd models/ | |
./gen_all.sh | |
- name: Build (test) | |
run: | | |
cd models/ | |
./build_all.sh test | |
- name: Run tests | |
run: | | |
cd models/ | |
./test_all.sh | |
- name: Build (prod) | |
run: | | |
cd models/ | |
./build_all.sh test | |
# TODO publish docker image | |
# Configure python | |
- uses: actions/setup-python@v3 | |
with: | |
python-version: '3.10' | |
cache: 'pip' | |
- run: pip install -r test_reporting/requirements.txt | |
# Gather test results | |
- name: Gather results | |
run: | | |
mkdir -p test_reporting/results | |
find models/ -name test_results -exec cp -r {} test_reporting/results/ \; | |
# Get a shortened SHA | |
- name: Shorten SHA | |
id: short_sha | |
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" | |
# Generate the report | |
- name: Generate JUnit report | |
run: | | |
cd test_reporting | |
python generate-report.py ${{ github.head_ref || github.ref_name }} ${{ steps.short_sha.outputs.sha_short }} | |
- run: mkdir -p test_reporting/summaries && cp test_reporting/target/surefire-reports/* test_reporting/summaries | |
# Generate surefire report | |
- uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '11' | |
cache: 'maven' | |
- run: | | |
cd test_reporting | |
mvn site | |
# Get the existing summaries for this branch | |
- name: Download summaries | |
uses: prewk/s3-cp-action@v2 | |
with: | |
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
source: 's3://${{ secrets.AWS_S3_BUCKET }}/munin/${{ github.head_ref || github.ref_name }}/surefire-reports' | |
dest: 'test_reporting/summaries' | |
flags: --recursive | |
# Generate the test history | |
- name: Generate history | |
run: | | |
cd test_reporting | |
python generate-history.py | |
# Aggregate results | |
- name: Aggregate results | |
run: | | |
cd test_reporting | |
mkdir dist | |
cp target/site/surefire-report.html dist/index.html | |
cp target/site/history.html dist/ | |
cp -r target/surefire-reports dist/ | |
# Upload the report | |
- name: Archive test results | |
uses: actions/upload-artifact@v3 | |
with: | |
name: test-reports | |
path: test_reporting/dist/ | |
# Publish to S3 | |
- uses: jakejarvis/s3-sync-action@master | |
with: | |
args: --acl public-read --follow-symlinks | |
env: | |
SOURCE_DIR: test_reporting/dist/ | |
DEST_DIR: "munin/${{ github.head_ref || github.ref_name }}" | |
# Publish to S3 permalink | |
- uses: jakejarvis/s3-sync-action@master | |
with: | |
args: --acl public-read --follow-symlinks | |
env: | |
SOURCE_DIR: test_reporting/dist/ | |
DEST_DIR: "munin/${{ steps.short_sha.outputs.sha_short }}" | |
# Comment on the PR with a link to the test results | |
- uses: marocchino/sticky-pull-request-comment@v2 | |
with: | |
hide_and_recreate: true | |
hide_classify: "OUTDATED" | |
message: | | |
Test results for branch "${{ github.head_ref || github.ref_name }}": <https://s3.amazonaws.com/${{ secrets.AWS_S3_BUCKET }}/munin/${{ github.head_ref || github.ref_name }}/index.html> | |
Permanent link for this run: <https://s3.amazonaws.com/${{ secrets.AWS_S3_BUCKET }}/munin/${{ steps.short_sha.outputs.sha_short }}/index.html> | |
# Fail check if any failures or errors exist | |
- name: Check failures | |
run: | | |
cd test_reporting | |
python generate-report.py -check |