ci: extract tests jobs into reusable workflow
This commit is contained in:
parent
87f0781ff3
commit
e29f714794
164
.github/workflows/build.yml
vendored
164
.github/workflows/build.yml
vendored
|
@ -100,171 +100,21 @@ jobs:
|
|||
# -----------------------------------------------------------------
|
||||
# TESTS
|
||||
# -----------------------------------------------------------------
|
||||
tests-python:
|
||||
name: Run Tests (Python)
|
||||
|
||||
tests:
|
||||
uses: ./.github/workflows/tests.yml
|
||||
if: ${{ github.event.inputs.skiptests == 'false' || github.ref_name == 'release' }}
|
||||
needs: [prepare]
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/ietf-tools/datatracker-app-base:latest
|
||||
|
||||
services:
|
||||
db:
|
||||
image: ghcr.io/ietf-tools/datatracker-db:latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare for tests
|
||||
run: |
|
||||
chmod +x ./dev/tests/prepare.sh
|
||||
sh ./dev/tests/prepare.sh
|
||||
|
||||
- name: Ensure DB is ready
|
||||
run: |
|
||||
/usr/local/bin/wait-for db:5432 -- echo "DB ready"
|
||||
|
||||
- name: Run all tests
|
||||
shell: bash
|
||||
run: |
|
||||
echo "Running checks..."
|
||||
./ietf/manage.py check
|
||||
./ietf/manage.py migrate --fake-initial
|
||||
echo "Validating migrations..."
|
||||
if ! ( ietf/manage.py makemigrations --dry-run --check --verbosity 3 ) ; then
|
||||
echo "Model changes without migrations found."
|
||||
exit 1
|
||||
fi
|
||||
echo "Running tests..."
|
||||
if [[ "x${{ github.event.inputs.ignoreLowerCoverage }}" == "xtrue" ]]; then
|
||||
echo "Lower coverage failures will be ignored."
|
||||
./ietf/manage.py test --validate-html-harder --settings=settings_test --ignore-lower-coverage
|
||||
else
|
||||
./ietf/manage.py test --validate-html-harder --settings=settings_test
|
||||
fi
|
||||
coverage xml
|
||||
with:
|
||||
ignoreLowerCoverage: ${{ github.event.inputs.ignoreLowerCoverage }}
|
||||
|
||||
- name: Upload Coverage Results to Codecov
|
||||
uses: codecov/codecov-action@v3.1.4
|
||||
with:
|
||||
files: coverage.xml
|
||||
|
||||
- name: Convert Coverage Results
|
||||
if: ${{ always() }}
|
||||
run: |
|
||||
mv latest-coverage.json coverage.json
|
||||
|
||||
- name: Upload Coverage Results as Build Artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
if: ${{ always() }}
|
||||
with:
|
||||
name: coverage
|
||||
path: coverage.json
|
||||
|
||||
tests-playwright:
|
||||
name: Run Tests (Playwright)
|
||||
if: ${{ github.event.inputs.skiptests == 'false' || github.ref_name == 'release' }}
|
||||
needs: [prepare]
|
||||
runs-on: macos-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
project: [chromium, firefox]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '18'
|
||||
|
||||
- name: Run all tests
|
||||
run: |
|
||||
echo "Installing dependencies..."
|
||||
yarn
|
||||
echo "Installing Playwright..."
|
||||
cd playwright
|
||||
mkdir test-results
|
||||
npm ci
|
||||
npx playwright install --with-deps ${{ matrix.project }}
|
||||
echo "Running tests..."
|
||||
npx playwright test --project=${{ matrix.project }}
|
||||
|
||||
- name: Upload Report
|
||||
uses: actions/upload-artifact@v3
|
||||
if: ${{ always() }}
|
||||
continue-on-error: true
|
||||
with:
|
||||
name: playwright-results-${{ matrix.project }}
|
||||
path: playwright/test-results/
|
||||
if-no-files-found: ignore
|
||||
|
||||
tests-playwright-legacy:
|
||||
name: Run Tests (Playwright Legacy)
|
||||
if: ${{ github.event.inputs.skiptests == 'false' || github.ref_name == 'release' }}
|
||||
needs: [prepare]
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/ietf-tools/datatracker-app-base:latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
project: [chromium, firefox]
|
||||
|
||||
services:
|
||||
db:
|
||||
image: ghcr.io/ietf-tools/datatracker-db:latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare for tests
|
||||
run: |
|
||||
chmod +x ./dev/tests/prepare.sh
|
||||
sh ./dev/tests/prepare.sh
|
||||
|
||||
- name: Ensure DB is ready
|
||||
run: |
|
||||
/usr/local/bin/wait-for db:5432 -- echo "DB ready"
|
||||
|
||||
- name: Start Datatracker
|
||||
run: |
|
||||
echo "Running checks..."
|
||||
./ietf/manage.py check
|
||||
echo "Starting datatracker..."
|
||||
./ietf/manage.py runserver 0.0.0.0:8000 --settings=settings_local &
|
||||
echo "Waiting for datatracker to be ready..."
|
||||
/usr/local/bin/wait-for localhost:8000 -- echo "Datatracker ready"
|
||||
|
||||
- name: Run all tests
|
||||
env:
|
||||
# Required to get firefox to run as root:
|
||||
HOME: ""
|
||||
run: |
|
||||
echo "Installing dependencies..."
|
||||
yarn
|
||||
echo "Installing Playwright..."
|
||||
cd playwright
|
||||
mkdir test-results
|
||||
npm ci
|
||||
npx playwright install --with-deps ${{ matrix.project }}
|
||||
echo "Running tests..."
|
||||
npx playwright test --project=${{ matrix.project }} -c playwright-legacy.config.js
|
||||
|
||||
- name: Upload Report
|
||||
uses: actions/upload-artifact@v3
|
||||
if: ${{ always() }}
|
||||
continue-on-error: true
|
||||
with:
|
||||
name: playwright-legacy-results-${{ matrix.project }}
|
||||
path: playwright/test-results/
|
||||
if-no-files-found: ignore
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# RELEASE
|
||||
# -----------------------------------------------------------------
|
||||
release:
|
||||
name: Make Release
|
||||
if: ${{ !failure() && !cancelled() }}
|
||||
needs: [tests-python, tests-playwright, tests-playwright-legacy, prepare]
|
||||
needs: [tests, prepare]
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
SHOULD_DEPLOY: ${{needs.prepare.outputs.should_deploy}}
|
||||
|
@ -389,7 +239,7 @@ jobs:
|
|||
notify:
|
||||
name: Notify
|
||||
if: ${{ always() }}
|
||||
needs: [prepare, tests-python, tests-playwright, tests-playwright-legacy, release]
|
||||
needs: [prepare, tests, release]
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
PKG_VERSION: ${{needs.prepare.outputs.pkg_version}}
|
||||
|
|
164
.github/workflows/tests.yml
vendored
Normal file
164
.github/workflows/tests.yml
vendored
Normal file
|
@ -0,0 +1,164 @@
|
|||
name: Reusable Tests Workflow
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
ignoreLowerCoverage:
|
||||
description: 'Ignore Lower Coverage'
|
||||
default: false
|
||||
required: true
|
||||
type: boolean
|
||||
|
||||
jobs:
|
||||
tests-python:
|
||||
name: Run Tests (Python)
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/ietf-tools/datatracker-app-base:latest
|
||||
|
||||
services:
|
||||
db:
|
||||
image: ghcr.io/ietf-tools/datatracker-db:latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare for tests
|
||||
run: |
|
||||
chmod +x ./dev/tests/prepare.sh
|
||||
sh ./dev/tests/prepare.sh
|
||||
|
||||
- name: Ensure DB is ready
|
||||
run: |
|
||||
/usr/local/bin/wait-for db:5432 -- echo "DB ready"
|
||||
|
||||
- name: Run all tests
|
||||
shell: bash
|
||||
run: |
|
||||
echo "Running checks..."
|
||||
./ietf/manage.py check
|
||||
./ietf/manage.py migrate --fake-initial
|
||||
echo "Validating migrations..."
|
||||
if ! ( ietf/manage.py makemigrations --dry-run --check --verbosity 3 ) ; then
|
||||
echo "Model changes without migrations found."
|
||||
exit 1
|
||||
fi
|
||||
echo "Running tests..."
|
||||
if [[ "x${{ github.event.inputs.ignoreLowerCoverage }}" == "xtrue" ]]; then
|
||||
echo "Lower coverage failures will be ignored."
|
||||
./ietf/manage.py test --validate-html-harder --settings=settings_test --ignore-lower-coverage
|
||||
else
|
||||
./ietf/manage.py test --validate-html-harder --settings=settings_test
|
||||
fi
|
||||
coverage xml
|
||||
|
||||
- name: Upload Coverage Results to Codecov
|
||||
uses: codecov/codecov-action@v3.1.4
|
||||
with:
|
||||
files: coverage.xml
|
||||
|
||||
- name: Convert Coverage Results
|
||||
if: ${{ always() }}
|
||||
run: |
|
||||
mv latest-coverage.json coverage.json
|
||||
|
||||
- name: Upload Coverage Results as Build Artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
if: ${{ always() }}
|
||||
with:
|
||||
name: coverage
|
||||
path: coverage.json
|
||||
|
||||
tests-playwright:
|
||||
name: Run Tests (Playwright)
|
||||
runs-on: macos-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
project: [chromium, firefox]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '18'
|
||||
|
||||
- name: Run all tests
|
||||
run: |
|
||||
echo "Installing dependencies..."
|
||||
yarn
|
||||
echo "Installing Playwright..."
|
||||
cd playwright
|
||||
mkdir test-results
|
||||
npm ci
|
||||
npx playwright install --with-deps ${{ matrix.project }}
|
||||
echo "Running tests..."
|
||||
npx playwright test --project=${{ matrix.project }}
|
||||
|
||||
- name: Upload Report
|
||||
uses: actions/upload-artifact@v3
|
||||
if: ${{ always() }}
|
||||
continue-on-error: true
|
||||
with:
|
||||
name: playwright-results-${{ matrix.project }}
|
||||
path: playwright/test-results/
|
||||
if-no-files-found: ignore
|
||||
|
||||
tests-playwright-legacy:
|
||||
name: Run Tests (Playwright Legacy)
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/ietf-tools/datatracker-app-base:latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
project: [chromium, firefox]
|
||||
|
||||
services:
|
||||
db:
|
||||
image: ghcr.io/ietf-tools/datatracker-db:latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare for tests
|
||||
run: |
|
||||
chmod +x ./dev/tests/prepare.sh
|
||||
sh ./dev/tests/prepare.sh
|
||||
|
||||
- name: Ensure DB is ready
|
||||
run: |
|
||||
/usr/local/bin/wait-for db:5432 -- echo "DB ready"
|
||||
|
||||
- name: Start Datatracker
|
||||
run: |
|
||||
echo "Running checks..."
|
||||
./ietf/manage.py check
|
||||
./ietf/manage.py migrate --fake-initial
|
||||
echo "Starting datatracker..."
|
||||
./ietf/manage.py runserver 0.0.0.0:8000 --settings=settings_local &
|
||||
echo "Waiting for datatracker to be ready..."
|
||||
/usr/local/bin/wait-for localhost:8000 -- echo "Datatracker ready"
|
||||
|
||||
- name: Run all tests
|
||||
env:
|
||||
# Required to get firefox to run as root:
|
||||
HOME: ""
|
||||
run: |
|
||||
echo "Installing dependencies..."
|
||||
yarn
|
||||
echo "Installing Playwright..."
|
||||
cd playwright
|
||||
mkdir test-results
|
||||
npm ci
|
||||
npx playwright install --with-deps ${{ matrix.project }}
|
||||
echo "Running tests..."
|
||||
npx playwright test --project=${{ matrix.project }} -c playwright-legacy.config.js
|
||||
|
||||
- name: Upload Report
|
||||
uses: actions/upload-artifact@v3
|
||||
if: ${{ always() }}
|
||||
continue-on-error: true
|
||||
with:
|
||||
name: playwright-legacy-results-${{ matrix.project }}
|
||||
path: playwright/test-results/
|
||||
if-no-files-found: ignore
|
Loading…
Reference in a new issue