From abc88bd9bcbf3f2cecc9016d8c0cd828d4721e21 Mon Sep 17 00:00:00 2001 From: Jiji14 Date: Tue, 5 Dec 2023 14:03:32 -0800 Subject: [PATCH 1/5] run coverage workflow only when PR is ready --- .github/workflows/code-coverage.yml | 34 +++++++++++++++++++++++++++++ .github/workflows/serve-install.yml | 7 ------ 2 files changed, 34 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/code-coverage.yml diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml new file mode 100644 index 000000000..c1f0785a8 --- /dev/null +++ b/.github/workflows/code-coverage.yml @@ -0,0 +1,34 @@ +name: code coverage +on: + pull_request: + types: + - opened + - reopened + - synchronize + - ready_for_review + +jobs: + run-codecov: + if: github.event.pull_request.draft == false + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: "21" + + - name: Install dependencies + run: npm install jest + + - name: Run Jest tests + run: npm run test + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 + with: + files: ./coverage/coverage-final.json + flags: unit + fail_ci_if_error: ${{ github.repository == 'e-mission/e-mission-phone' }} + \ No newline at end of file diff --git a/.github/workflows/serve-install.yml b/.github/workflows/serve-install.yml index f7902b2ea..c78ce1f86 100644 --- a/.github/workflows/serve-install.yml +++ b/.github/workflows/serve-install.yml @@ -64,13 +64,6 @@ jobs: run: | npx jest - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v3 - with: - files: ./coverage/coverage-final.json - flags: unit - fail_ci_if_error: ${{ github.repository == 'e-mission/e-mission-phone' }} - # TODO: figure out how to check that a server started correctly # - name: Try starting it # run: npx run serve From b3577443c887718df64a049f9e3bc95e1c46cdc5 Mon Sep 17 00:00:00 2001 From: Jiji14 Date: Tue, 5 Dec 2023 14:17:04 -0800 Subject: [PATCH 2/5] include shell command --- .github/workflows/code-coverage.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index c1f0785a8..8ed8d6063 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -20,10 +20,13 @@ jobs: node-version: "21" - name: Install dependencies + shell: bash -l {0} run: npm install jest - name: Run Jest tests - run: npm run test + shell: bash -l {0} + run: | + npx jest - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v3 From a6d99321fb5cf63fdf142d16cfdfc308033ece25 Mon Sep 17 00:00:00 2001 From: Jiji14 Date: Tue, 5 Dec 2023 14:33:06 -0800 Subject: [PATCH 3/5] setup the serve environment for test --- .github/workflows/code-coverage.yml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 8ed8d6063..b6186188b 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -12,16 +12,10 @@ jobs: if: github.event.pull_request.draft == false runs-on: macos-latest steps: - - uses: actions/checkout@v2 - - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: "21" - - - name: Install dependencies + - name: Setup the serve environment shell: bash -l {0} - run: npm install jest + run: | + bash setup/setup_serve.sh - name: Run Jest tests shell: bash -l {0} From 18539f584739ae24a43507928fad889f501d7673 Mon Sep 17 00:00:00 2001 From: Jiji14 Date: Tue, 5 Dec 2023 14:39:28 -0800 Subject: [PATCH 4/5] check out the repository and activate the environment --- .github/workflows/code-coverage.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index b6186188b..b0e94db22 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -12,6 +12,9 @@ jobs: if: github.event.pull_request.draft == false runs-on: macos-latest steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + - name: Setup the serve environment shell: bash -l {0} run: | @@ -20,6 +23,7 @@ jobs: - name: Run Jest tests shell: bash -l {0} run: | + source setup/activate_serve.sh npx jest - name: Upload coverage reports to Codecov From 1901f4c72a91a0c95485189d9369d4043630cd60 Mon Sep 17 00:00:00 2001 From: Jiji14 Date: Tue, 12 Dec 2023 15:54:51 -0800 Subject: [PATCH 5/5] remove Jest from the osx-serve-install workflow to avoid running the tests twice --- .github/workflows/serve-install.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/serve-install.yml b/.github/workflows/serve-install.yml index c78ce1f86..3c42514e5 100644 --- a/.github/workflows/serve-install.yml +++ b/.github/workflows/serve-install.yml @@ -59,11 +59,6 @@ jobs: echo "ionic version" npx ionic --version - - name: Run Jest tests - shell: bash -l {0} - run: | - npx jest - # TODO: figure out how to check that a server started correctly # - name: Try starting it # run: npx run serve