Use affected only on PRs, excluding master

This commit is contained in:
Adria Navarro 2023-08-09 18:02:45 +03:00
parent 0ed9114a89
commit 1c6b17ee32
1 changed files with 37 additions and 6 deletions

View File

@ -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