diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 25feab648..eb0556ee8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,10 +15,11 @@ on: branches: [ "master" ] jobs: - test: + unit: + name: Unit tests runs-on: ubuntu-latest strategy: - fail-fast: false + fail-fast: true matrix: python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] steps: @@ -33,11 +34,54 @@ jobs: run: make lint - name: test run: make test - - name: test update + instance-changes: + name: Instance tests + runs-on: ubuntu-latest + needs: [unit] + strategy: + fail-fast: true + matrix: + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: make install + - name: Test instance changes on this branch + run: make test-changes T_FLAGS+='-n 10 --json-report --json-report-file=report/changes-report.json' + - name: Test all instances (ok to fail) run: | - make report T_FLAGS+='-n 10' || true + make report! T_FLAGS+='-n 10' || true # Only run summary once - - name: summary + # bleargh + - name: all summary if: (success() || failure()) && matrix.python-version == '3.8' run: | - make github-summary >> $GITHUB_STEP_SUMMARY + make github-summary T_FILE='changes-report.json' >> $GITHUB_STEP_SUMMARY + [[ -f report/report.json ]] && make github-summary >> $GITHUB_STEP_SUMMARY || true + python2: + name: test (2.7) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python 2.7 + uses: MatteoH2O1999/setup-python@v4 + with: + python-version: '2.7' + allow-build: info + cache-build: true + - name: Install dependencies + run: make install + - name: lint + run: make lint + - name: test + run: make test + - name: test update + run: | + # allowed to fail for test runs + make test-update T_FLAGS+='-n 10' || true diff --git a/.github/workflows/test_changes.yml b/.github/workflows/test_changes.yml deleted file mode 100644 index 3d9d6ea5d..000000000 --- a/.github/workflows/test_changes.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: networks that changed on this branch -run-name: Check changes between branch and master - -env: - PYBIKES_CYCLOCITY: ${{ secrets.PYBIKES_CYCLOCITY }} - PYBIKES_BYSYKKEL: ${{ secrets.PYBIKES_BYSYKKEL }} - PYBIKES_WEELO_CLIENT_ID: ${{ secrets.PYBIKES_WEELO_CLIENT_ID }} - PYBIKES_WEELO_CLIENT_SECRET: ${{ secrets.PYBIKES_WEELO_CLIENT_SECRET }} - PYBIKES_DEUTSCHEBAHN_CLIENT_ID: ${{ secrets.PYBIKES_DEUTSCHEBAHN_CLIENT_ID }} - PYBIKES_DEUTSCHEBAHN_CLIENT_SECRET: ${{ secrets.PYBIKES_DEUTSCHEBAHN_CLIENT_SECRET }} - -on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] - -jobs: - test: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: make install - - name: Test instance changes on this branch - run: make test-changes T_FLAGS+='-n 10 --json-report --json-report-file=report/report.json' - # Only run summary once - - name: summary - if: (success() || failure()) && matrix.python-version == '3.8' - run: | - make github-summary >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/test_python2.yml b/.github/workflows/test_python2.yml deleted file mode 100644 index 1f0d0228b..000000000 --- a/.github/workflows/test_python2.yml +++ /dev/null @@ -1,41 +0,0 @@ -# There are still parts of the project using python2.7 so it's a good idea -# to check if it works at all - -name: pybikes (2.7) - -env: - PYBIKES_CYCLOCITY: ${{ secrets.PYBIKES_CYCLOCITY }} - PYBIKES_BYSYKKEL: ${{ secrets.PYBIKES_BYSYKKEL }} - PYBIKES_WEELO_CLIENT_ID: ${{ secrets.PYBIKES_WEELO_CLIENT_ID }} - PYBIKES_WEELO_CLIENT_SECRET: ${{ secrets.PYBIKES_WEELO_CLIENT_SECRET }} - PYBIKES_DEUTSCHEBAHN_CLIENT_ID: ${{ secrets.PYBIKES_DEUTSCHEBAHN_CLIENT_ID }} - PYBIKES_DEUTSCHEBAHN_CLIENT_SECRET: ${{ secrets.PYBIKES_DEUTSCHEBAHN_CLIENT_SECRET }} - -on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] - -jobs: - test: - name: test (2.7) - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Set up Python 2.7 - uses: MatteoH2O1999/setup-python@v4 - with: - python-version: '2.7' - allow-build: info - cache-build: true - - name: Install dependencies - run: make install - - name: lint - run: make lint - - name: test - run: make test - - name: test update - run: | - # allowed to fail for test runs - make test-update T_FLAGS+='-n 10' || true diff --git a/Makefile b/Makefile index 9115379fe..7d62d193c 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ T_FLAGS = +R_FILE ?= report.json .PHONY: install install: @@ -22,27 +23,30 @@ lint: flake8 pybikes tests --count --select=E9,F63,F7,F82 --show-source --statistics flake8 pybikes tests --count --exit-zero --max-complexity=10 --max-line-length=88 --statistics -report/report.json: - pytest tests -m update --json-report --json-report-file=report/report.json $(T_FLAGS) +report/$(R_FILE): + pytest tests -m update $(T_FLAGS) --json-report --json-report-file=report/$(R_FILE) .PHONY: report -report: report/report.json +report: report/$(R_FILE) + +.PHONY: report! +report!: clean report .PHONY: summary -summary: report/report.json - @./utils/report.py report/report.json +summary: report/$(R_FILE) + @./utils/report.py report/$(R_FILE) .PHONY: map -map: report/report.json - @./utils/report.py report/report.json --template utils/map.tpl.html > report/map.html +map: report/$(R_FILE) + @./utils/report.py report/$(R_FILE) --template utils/map.tpl.html > report/map.html @open report/map.html || xdg-open report/map.html .PHONY: map! map!: clean map .PHONY: github-summary -github-summary: report/report.json - @./utils/report.py report/report.json --template utils/github-summary.tpl.md +github-summary: report/$(R_FILE) + @./utils/report.py report/$(R_FILE) --template utils/github-summary.tpl.md .PHONY: clean clean: clean-report