From 1f18b4ac04a245689721caf993ddebdf7fc468f0 Mon Sep 17 00:00:00 2001 From: Giovanni Sanchez <108043524+sisyphusSmiling@users.noreply.github.com> Date: Mon, 18 Mar 2024 17:33:09 -0500 Subject: [PATCH] add Cadence tests to CI workflow --- .github/workflows/cadence_test.yml | 39 ++++++++++++++++++++++++++++++ local/normalize_coverage_report.sh | 3 +++ local/run_cadence_tests.sh | 1 + 3 files changed, 43 insertions(+) create mode 100644 .github/workflows/cadence_test.yml create mode 100644 local/normalize_coverage_report.sh create mode 100644 local/run_cadence_tests.sh diff --git a/.github/workflows/cadence_test.yml b/.github/workflows/cadence_test.yml new file mode 100644 index 00000000..fee3a807 --- /dev/null +++ b/.github/workflows/cadence_test.yml @@ -0,0 +1,39 @@ +name: CI + +on: + pull_request: + branches: [main] + push: + branches: [main] + +jobs: + tests: + name: Flow CLI Tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: '1.20.x' + - uses: actions/cache@v1 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + - name: Install Flow CLI + run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/feature/stable-cadence/install.sh)" + - name: Flow CLI Version + run: flow version + - name: Update PATH + run: echo "/root/.local/bin" >> $GITHUB_PATH + - name: Run tests + run: sh local/run_cadence_tests.sh + - name: Normalize coverage report filepaths + run : sh ./local/normalize_coverage_report.sh + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + \ No newline at end of file diff --git a/local/normalize_coverage_report.sh b/local/normalize_coverage_report.sh new file mode 100644 index 00000000..8de7ee5f --- /dev/null +++ b/local/normalize_coverage_report.sh @@ -0,0 +1,3 @@ +sed -i 's/A.0000000000000007.SerializationInterfaces/cadence\contracts\/SerializationInterfaces.cdc/' coverage.lcov +sed -i 's/A.0000000000000007.Serialize/cadence\/contracts\/utils\/Serialize.cdc/' coverage.lcov +sed -i 's/A.0000000000000007.SerializeNFT/cadence\contracts\/SerializeNFT.cdc/' coverage.lcov \ No newline at end of file diff --git a/local/run_cadence_tests.sh b/local/run_cadence_tests.sh new file mode 100644 index 00000000..94e3a833 --- /dev/null +++ b/local/run_cadence_tests.sh @@ -0,0 +1 @@ +flow-c1 test --cover --covercode="contracts" --coverprofile="coverage.lcov" cadence/tests/*_tests.cdc \ No newline at end of file