Migrate tests to GitHub Actions #41
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: CI | |
on: | |
push: | |
branches-ignore: | |
- translations | |
pull_request: | |
branches-ignore: | |
- translations | |
jobs: | |
build-tests-image: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: docker/setup-buildx-action@v3 | |
- run: | | |
if echo "$GITHUB_BASE_REF-$GITHUB_HEAD_REF" | grep -Pqv '^[\\w-]+$'; then | |
echo 'Invalid branch name' | |
exit 1 | |
fi | |
make -C docker config | |
- uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: docker/Dockerfile.tests | |
tags: ghcr.io/metabrainz/musicbrainz-tests:${{ github.sha }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
push: true | |
js-perl-and-pgtap: | |
needs: build-tests-image | |
runs-on: ubuntu-latest | |
container: | |
image: ghcr.io/metabrainz/musicbrainz-tests:${{ github.sha }} | |
options: --user root | |
defaults: | |
run: | |
working-directory: /home/musicbrainz/musicbrainz-server | |
steps: | |
- run: | | |
./docker/musicbrainz-tests/run_js_perl_and_pgtap_tests.sh | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: js_nyc_output | |
path: nyc_output | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: js_perl_and_pgtap_junit_output | |
path: junit_output | |
selenium: | |
needs: build-tests-image | |
runs-on: ubuntu-latest | |
container: | |
image: ghcr.io/metabrainz/musicbrainz-tests:${{ github.sha }} | |
options: --user root | |
strategy: | |
matrix: | |
partition: [1, 2, 3, 4] | |
fail-fast: false | |
defaults: | |
run: | |
working-directory: /home/musicbrainz/musicbrainz-server | |
steps: | |
- run: | | |
SELENIUM_JS_OPTIONS='--run-partition ${{ matrix.partition }}/4' \ | |
./docker/musicbrainz-tests/run_selenium_tests.sh | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: selenium_${{ matrix.partition }}_service_logs | |
path: service_logs | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: selenium_${{ matrix.partition }}_nyc_output | |
path: nyc_output | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: selenium_${{ matrix.partition }}_junit_output | |
path: junit_output | |
generate-reports: | |
needs: [js-perl-and-pgtap, selenium] | |
if: always() | |
runs-on: ubuntu-latest | |
container: | |
image: ghcr.io/metabrainz/musicbrainz-tests:${{ github.sha }} | |
options: --user root | |
defaults: | |
run: | |
working-directory: /home/musicbrainz/musicbrainz-server | |
steps: | |
- if: always() | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: "*_nyc_output" | |
id: nyc_download | |
- if: steps.nyc_download.outcome == 'success' | |
run: | | |
sudo -E -H -u musicbrainz mkdir -p .nyc_output | |
mv \ | |
"$GITHUB_WORKSPACE"/*_nyc_output/*.json \ | |
.nyc_output/ | |
sudo -E -H -u musicbrainz ./node_modules/.bin/nyc report --reporter=html | |
mv coverage "$GITHUB_WORKSPACE" | |
id: nyc_merge | |
- if: steps.nyc_merge.outcome == 'success' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage_report | |
path: coverage | |
- if: always() | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: "*_junit_output" | |
id: junit_download | |
- if: steps.junit_download.outcome == 'success' | |
uses: mikepenz/action-junit-report@v5 | |
with: | |
report_paths: '*_junit_output/*.xml' | |
fail_on_failure: true | |
require_tests: true |