Skip to content

Commit

Permalink
feat(ci): enhance workflows logic for pull requests and improve job c…
Browse files Browse the repository at this point in the history
…onditions
  • Loading branch information
0x1026 committed Dec 4, 2024
1 parent 517c426 commit bc61500
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
permissions:
pull-requests: read
outputs:
images: ${{ steps.filter.outputs.changes }}
images: ${{ github.event_name == 'pull_request' && '["all"]' || steps.filter.outputs.changes }}
steps:
# https://github.com/actions/checkout/tree/11bd71901bbe5b1630ceea73d27597364c9af683
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
Expand All @@ -47,6 +47,8 @@ jobs:
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/running-variations-of-jobs-in-a-workflow#example-adding-configurations
matrix:
image: ${{ fromJSON(needs.changes.outputs.images) }}
exclude:
- image: all
include:
- image: urbantree
context: ./app
Expand Down
13 changes: 8 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ jobs:
urbantree:
name: 🧪 UrbanTree
runs-on: ubuntu-latest
if: ${{ contains(fromJSON(inputs.images), 'urbantree') }}
if: ${{ contains(inputs.images, 'all') || contains(fromJSON(inputs.images), 'urbantree') }}
defaults:
run:
working-directory: app
steps:
# https://github.com/actions/checkout/tree/11bd71901bbe5b1630ceea73d27597364c9af683
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
Expand Down Expand Up @@ -40,7 +43,6 @@ jobs:

- name: 🧪 Run PHPUnit tests with coverage
shell: bash
working-directory: app
run: ./vendor/bin/phpunit --log-junit junit.xml --coverage-clover=coverage.xml

# https://github.com/codecov/test-results-action/tree/9739113ad922ea0a9abb4b2c0f8bf6a4aa8ef820
Expand All @@ -61,7 +63,10 @@ jobs:
api:
name: 🧪 API
runs-on: ubuntu-latest
if: ${{ contains(fromJSON(inputs.images), 'api') }}
if: ${{ contains(inputs.images, 'all') || contains(fromJSON(inputs.images), 'api') }}
defaults:
run:
working-directory: api
steps:
# https://github.com/actions/checkout/tree/11bd71901bbe5b1630ceea73d27597364c9af683
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
Expand All @@ -80,12 +85,10 @@ jobs:

- name: 📦 Install Python dependencies
shell: bash
working-directory: api
run: pip install -r requirements-dev.txt

- name: 🧪 Run Python tests with coverage
shell: bash
working-directory: api
run: pytest tests --cov=./src --cov-report=xml --junitxml=junit.xml

# https://github.com/codecov/test-results-action/tree/9739113ad922ea0a9abb4b2c0f8bf6a4aa8ef820
Expand Down

0 comments on commit bc61500

Please sign in to comment.