add jobs for testing strategy branches #1
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
# Since we're using both the "require pull request" and "require merge queue" | |
# requirements for develop and master branches, there's no reason to run tests | |
# on every push. Instead, we're using the recommended "merge_group" formulation | |
# that runs status checks and reports them whenever a PR is added to the merge | |
# queue. | |
name: Run Python tests | |
on: [pull_request, merge_group] | |
jobs: | |
pytest_required_check: | |
runs-on: ubuntu-latest | |
# Here, we capture whether any files have changed to indicate we need to run | |
# python tests | |
outputs: | |
any_changed: ${{ steps.changed_files.outputs.any_changed }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get changed files | |
id: changed_files | |
uses: tj-actions/changed-files@v39 | |
with: | |
files: | | |
*.abcde | |
# *.py | |
# mathesar/** | |
# db/** | |
flake8_required_check: | |
runs-on: ubuntu-latest | |
# Here, we capture whether any files have changed to indicate we need to run | |
# python tests | |
outputs: | |
any_changed: ${{ steps.changed_files.outputs.any_changed }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get changed files | |
id: changed_files | |
uses: tj-actions/changed-files@v39 | |
with: | |
files: '**.py' | |
python_tests: | |
name: Run Python tests | |
runs-on: ubuntu-latest | |
needs: pytest_required_check | |
if: needs.pytest_required_check.outputs.any_changed == 'true' | |
strategy: | |
matrix: | |
pg-version: [13, 14, 15] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Copy env file | |
run: cp .env.example .env | |
# The code is checked out under uid 1001 - reset this to 1000 for the | |
# container to run tests successfully | |
- name: Fix permissions | |
run: sudo chown -R 1000:1000 . | |
- name: Build the stack | |
run: docker compose -f docker-compose.yml -f docker-compose.dev.yml up --build -d test-service | |
env: | |
PG_MAJOR: ${{ matrix.pg-version }} | |
- name: Run tests with pytest | |
run: docker exec mathesar_service_test ./run_pytest.sh | |
python_lint: | |
name: Run Python linter | |
runs-on: ubuntu-latest | |
needs: flake8_required_check | |
if: needs.flake8_required_check.outputs.any_changed == 'true' | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v4 | |
- name: Run flake8 | |
uses: julianwachholz/flake8-action@main | |
with: | |
checkName: "flake8" | |
path: "." | |
plugins: flake8-no-types | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
tests: | |
runs-on: ubuntu-latest | |
needs: python_tests | |
steps: | |
- name: Report success | |
run: echo "Python tests succeeded or skipped!" | |
lint: | |
runs-on: ubuntu-latest | |
needs: python_lint | |
steps: | |
- name: Report success | |
run: echo "Python linter succeeded or skipped!" |