Skip to content

Commit

Permalink
ci(github): fix path filtering of required but skipped workflows
Browse files Browse the repository at this point in the history
1. Migrated from the stock GitHub Actions yaml syntax to using this custom
action[1] that allows us to skip the running of jobs based on path filtering.
The difference compared to the old solution is that this one won't just
skip the checks that are marked as required but it will pass them instead.
2. This is a suboptimal solution because we have to run each job so that
the code can be checked out and then examined for changes. This uses
resources that we should not have to expend, but currently there's no way
to avoid this because of the way the GitHub handles required checks that
are skipped (which cause a deadlock on the CI at the currently).
3. There is a relevant discussion thread about the problem here [2] which
should be voted on heavily so that it gets the necessary attention from
the product teams at GitHub.

Quoting the relevant part of the GitHub documentation directly:

> Handling skipped but required checks
> Warning: If a workflow is skipped due to path filtering, branch
> filtering or a commit message, then checks associated with that workflow
> will remain in a "Pending" state. A pull request that requires those
> checks to be successful will be blocked from merging.
>
> For this reason you should not use path or branch filtering to skip
>  workflow runs if the workflow is required. For more information, see
>  "Skipping workflow runs" and "Required workflows."
>
> If, however, a job within a workflow is skipped due to a conditional,
> it will report its status as "Success". For more information, see
> "Using conditions to control job execution."

**Source** (link broken into multiple lines to avoid it being longer than
100 characters):

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/
collaborating-on-repositories-with-code-quality-features/
troubleshooting-required-status-checks#handling-skipped-but-required-checks

[1] https://github.com/dorny/paths-filter
[2] https://github.com/orgs/community/discussions/44490

Signed-off-by: Peter Somogyvari <[email protected]>
Signed-off-by: Sandeep Nishad <[email protected]>
  • Loading branch information
petermetz authored and sandeepnRES committed Jan 17, 2024
1 parent 1fb2551 commit 6465e93
Show file tree
Hide file tree
Showing 11 changed files with 665 additions and 320 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/cacti-dev-container-vscode-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: connector-fabric-publish

env:
NODEJS_VERSION: v20.3.0
IMAGE_NAME: cacti-dev-container-vscode

on:
push:
Expand All @@ -13,9 +14,6 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
IMAGE_NAME: cacti-dev-container-vscode

jobs:
# Push image to GitHub Packages.
# See also https://docs.docker.com/docker-hub/builds/
Expand Down
31 changes: 18 additions & 13 deletions .github/workflows/test_weaver-asset-exchange-besu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,8 @@ on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
paths:
- '.github/workflows/test_weaver-**'
- 'weaver/**'
- '!weaver/docs/**'
- '!weaver/rfcs/**'
- '!weaver/resources/**'
pull_request:
branches: [ main ]
paths:
- '.github/workflows/test_weaver-**'
- 'weaver/**'
- '!weaver/docs/**'
- '!weaver/rfcs/**'
- '!weaver/resources/**'

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand All @@ -34,9 +22,24 @@ concurrency:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
check_code_changed:
outputs:
status: ${{ steps.changes.outputs.weaver_code_changed }}
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]

- uses: dorny/[email protected]
id: changes
with:
filters: |
weaver_code_changed:
- './weaver/**!(*.md|*.css|*.html|*.jpg|*.jpeg|*.png)'
- '.github/workflows/test_weaver-asset-exchange-besu.yaml'
asset-exchange-besu:
if: ${{ false }}
needs: check_code_changed
if: ${{ false && needs.check_code_changed.outputs.status == 'true' }}
# The type of runner that the job will run on
runs-on: ubuntu-latest

Expand Down Expand Up @@ -216,6 +219,8 @@ jobs:
working-directory: weaver/samples/besu/besu-cli

asset-exchange-besu-local:
needs: check_code_changed
if: needs.check_code_changed.outputs.status == 'true'
# The type of runner that the job will run on
runs-on: ubuntu-latest

Expand Down
42 changes: 28 additions & 14 deletions .github/workflows/test_weaver-asset-exchange-corda.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,8 @@ on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
paths:
- '.github/workflows/test_weaver-**'
- 'weaver/**'
- '!weaver/docs/**'
- '!weaver/rfcs/**'
- '!weaver/resources/**'
pull_request:
branches: [ main ]
paths:
- '.github/workflows/test_weaver-**'
- 'weaver/**'
- '!weaver/docs/**'
- '!weaver/rfcs/**'
- '!weaver/resources/**'

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand All @@ -35,9 +23,24 @@ concurrency:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
check_code_changed:
outputs:
status: ${{ steps.changes.outputs.weaver_code_changed }}
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]

- uses: dorny/[email protected]
id: changes
with:
filters: |
weaver_code_changed:
- './weaver/**!(*.md|*.css|*.html|*.jpg|*.jpeg|*.png)'
- '.github/workflows/test_weaver-asset-exchange-corda.yaml'
asset-exchange-corda:
if: ${{ false }}
needs: check_code_changed
if: ${{ false && needs.check_code_changed.outputs.status == 'true' }}
# The type of runner that the job will run on
runs-on: ubuntu-latest

Expand Down Expand Up @@ -133,6 +136,8 @@ jobs:
working-directory: weaver/samples/corda/corda-simple-application

asset-exchange-corda-local:
needs: check_code_changed
if: needs.check_code_changed.outputs.status == 'true'
# The type of runner that the job will run on
runs-on: ubuntu-latest

Expand Down Expand Up @@ -227,7 +232,8 @@ jobs:
working-directory: weaver/samples/corda/corda-simple-application

house-token-exchange-corda:
if: ${{ false }}
needs: check_code_changed
if: ${{ false && needs.check_code_changed.outputs.status == 'true' }}
# The type of runner that the job will run on
runs-on: ubuntu-latest

Expand All @@ -236,6 +242,14 @@ jobs:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/[email protected]

- uses: dorny/[email protected]
id: changes
with:
filters: |
weaver_code_changed:
- './weaver/**!(*.md|*.css|*.html|*.jpg|*.jpeg|*.png)'
- '.github/workflows/test_weaver-asset-exchange-corda.yaml'
- name: Set up JDK 8
uses: actions/[email protected]
with:
Expand Down
35 changes: 22 additions & 13 deletions .github/workflows/test_weaver-asset-exchange-fabric.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,9 @@ on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
paths:
- '.github/workflows/test_weaver-**'
- 'weaver/**'
- '!weaver/docs/**'
- '!weaver/rfcs/**'
- '!weaver/resources/**'

pull_request:
branches: [ main ]
paths:
- '.github/workflows/test_weaver-**'
- 'weaver/**'
- '!weaver/docs/**'
- '!weaver/rfcs/**'
- '!weaver/resources/**'

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand All @@ -38,9 +27,24 @@ concurrency:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
check_code_changed:
outputs:
status: ${{ steps.changes.outputs.weaver_code_changed }}
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]

- uses: dorny/[email protected]
id: changes
with:
filters: |
weaver_code_changed:
- './weaver/**!(*.md|*.css|*.html|*.jpg|*.jpeg|*.png)'
- '.github/workflows/test_weaver-asset-exchange-fabric.yaml'
asset-exchange-fabric:
if: ${{ false }}
needs: check_code_changed
if: ${{ false && needs.check_code_changed.outputs.status == 'true' }}
# The type of runner that the job will run on
runs-on: ubuntu-latest

Expand Down Expand Up @@ -71,15 +75,18 @@ jobs:
sed -i "s/<personal-access-token>/${{ secrets.GITHUB_TOKEN }}/g" .npmrc
cat .npmrc
working-directory: weaver/samples/fabric/fabric-cli

- name: Build Fabric CLI
run: npm install
working-directory: weaver/samples/fabric/fabric-cli

- name: Setup Fabric CLI Config
run: |
echo ${GITHUB_WORKSPACE}
cp config.template.json config.json
sed -i "s#<PATH-TO-WEAVER>#${GITHUB_WORKSPACE}/weaver#g" config.json
working-directory: weaver/samples/fabric/fabric-cli

- name: Setup Fabric CLI ENV
run: |
echo ${GITHUB_WORKSPACE}
Expand Down Expand Up @@ -114,6 +121,8 @@ jobs:
working-directory: weaver/samples/fabric/fabric-cli

asset-exchange-fabric-local:
needs: check_code_changed
if: needs.check_code_changed.outputs.status == 'true'
# if: ${{ false }}
# The type of runner that the job will run on
runs-on: ubuntu-latest
Expand Down
Loading

0 comments on commit 6465e93

Please sign in to comment.