Commit 1bba5f09 authored by Maurelian's avatar Maurelian

ci(contracts): only run codecov if contracts package is modified

In order to skip running the CodeCov job when it isn't relevant, a new job was added to the ts-packges workflow. For a PR, this job identifies all the files modified between the base branch and the tip of the PR branch, and writes to a variable which can be used to decide if subsequent jobs should run.

Github Actions provides an easy method for achieving this at the level of a workflow, but not for specific jobs within a workflow.
parent dc27deae
...@@ -61,8 +61,42 @@ jobs: ...@@ -61,8 +61,42 @@ jobs:
env: env:
CC_SECRET: ${{ secrets.CC_SECRET }} CC_SECRET: ${{ secrets.CC_SECRET }}
# A hack that allows running a job only if a specific directory changed.
# Ref: https://github.community/t/run-job-only-if-folder-changed/118292
is-contracts-package:
name: Check files
outputs:
run_coverage: ${{ steps.check_files.outputs.run_coverage }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- run: git fetch origin $GITHUB_BASE_REF
- name: check modified files
id: check_files
run: |
echo "=============== list modified files ==============="
git diff --name-only origin/$GITHUB_BASE_REF HEAD -- .
echo "========== check paths of modified files =========="
git diff --name-only origin/$GITHUB_BASE_REF HEAD -- . > files.txt
while IFS= read -r file
do
echo $file
if [[ $file != packages/contracts/* ]]; then
echo "This modified files are not in the contracts package."
echo "::set-output name=run_coverage::false"
break
else
echo "::set-output name=run_coverage::true"
fi
done < files.txt
test-coverage: test-coverage:
name: Generate test coverage name: Generate test coverage
needs: is-contracts-package
if: needs.is-contracts-package.outputs.run_coverage == 'true'
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment