From 1c6b17ee326883aa3e4e545495210f411d1a287e Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 9 Aug 2023 18:02:45 +0300 Subject: [PATCH] Use affected only on PRs, excluding master --- .github/workflows/budibase_ci.yml | 43 ++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/.github/workflows/budibase_ci.yml b/.github/workflows/budibase_ci.yml index cc1244e01a..af135b757b 100644 --- a/.github/workflows/budibase_ci.yml +++ b/.github/workflows/budibase_ci.yml @@ -18,7 +18,8 @@ env: BRANCH: ${{ github.event.pull_request.head.ref }} BASE_BRANCH: ${{ github.event.pull_request.base.ref}} PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} - NX_BASE_BRANCH: origin/${{ github.base_ref || 'master'}} + NX_BASE_BRANCH: origin/${{ github.base_ref }} + USE_NX_AFFECTED: ${{ github.event_name == 'pull_request' && github.base_ref != 'master'}} jobs: lint: @@ -66,9 +67,21 @@ jobs: - run: yarn --frozen-lockfile # Run build all the projects - - run: yarn build --since=${{ env.NX_BASE_BRANCH }} + - name: Build + run: | + if [[ ${{ env.USE_NX_AFFECTED }} ]]; then + yarn build --since=${{ env.NX_BASE_BRANCH }} + else + yarn build + fi # Check the types of the projects built via esbuild - - run: yarn check:types --since=${{ env.NX_BASE_BRANCH }} + - name: Check types + run: | + if [[ ${{ env.USE_NX_AFFECTED }} ]]; then + yarn check:types --since=${{ env.NX_BASE_BRANCH }} + else + yarn check:types + fi test-libraries: runs-on: ubuntu-latest @@ -92,7 +105,13 @@ jobs: node-version: 18.x cache: "yarn" - run: yarn --frozen-lockfile - - run: yarn test --ignore=@budibase/worker --ignore=@budibase/server --ignore=@budibase/pro --since=${{ env.NX_BASE_BRANCH }} + - name: Test + run: | + if [[ ${{ env.USE_NX_AFFECTED }} ]]; then + yarn test --ignore=@budibase/worker --ignore=@budibase/server --ignore=@budibase/pro --since=${{ env.NX_BASE_BRANCH }} + else + yarn test --ignore=@budibase/worker --ignore=@budibase/server --ignore=@budibase/pro + fi - uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos @@ -122,7 +141,13 @@ jobs: cache: "yarn" - run: yarn --frozen-lockfile - name: Test worker and server - run: yarn test --scope=@budibase/worker --scope=@budibase/server --since=${{ env.NX_BASE_BRANCH }} + run: | + if [[ ${{ env.USE_NX_AFFECTED }} ]]; then + yarn test --scope=@budibase/worker --scope=@budibase/server --since=${{ env.NX_BASE_BRANCH }} + else + yarn test --scope=@budibase/worker --scope=@budibase/server + fi + - uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN || github.token }} # not required for public repos @@ -146,7 +171,13 @@ jobs: node-version: 18.x cache: "yarn" - run: yarn --frozen-lockfile - - run: yarn test --scope=@budibase/pro --since=${{ env.NX_BASE_BRANCH }} + - name: Test + run: | + if [[ ${{ env.USE_NX_AFFECTED }} ]]; then + yarn test --scope=@budibase/pro --since=${{ env.NX_BASE_BRANCH }} + else + yarn test --scope=@budibase/pro + fi integration-test: runs-on: ubuntu-latest