-
Notifications
You must be signed in to change notification settings - Fork 77
65 lines (59 loc) · 2.4 KB
/
integration-test-workflow.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
name: "Integration test workflow"
on:
workflow_call:
inputs:
main-branch-name:
required: false
type: string
default: main
runs-on:
required: false
type: string
default: ubuntu-latest
working-directory:
required: false
type: string
jobs:
main:
runs-on: ${{ inputs.runs-on }}
name: Run
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
name: Checkout [Pull Request]
if: ${{ github.event_name == 'pull_request' }}
with:
# By default, PRs will be checked-out based on the Merge Commit, but we want the actual branch HEAD.
ref: ${{ github.event.pull_request.head.sha }}
# We need to fetch all branches and commits so that Nx affected has a base to compare against.
fetch-depth: 0
- uses: actions/checkout@v4
name: Checkout [Default Branch]
if: ${{ github.event_name != 'pull_request' }}
with:
# We need to fetch all branches and commits so that Nx affected has a base to compare against.
fetch-depth: 0
- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: ./
with:
main-branch-name: ${{ inputs.main-branch-name }}
- name: Verify default PR Workflow
if: ${{ github.event_name == 'pull_request' }}
run: |
BASE_SHA=$(echo $(git merge-base origin/${{github.base_ref}} HEAD))
HEAD_SHA=$(git rev-parse HEAD)
node -e "if(process.env.NX_BASE == '${BASE_SHA}') console.log('Base set correctly'); else { throw new Error('Base not set correctly!');}"
node -e "if(process.env.NX_HEAD == '${HEAD_SHA}') console.log('Head set correctly'); else { throw new Error('Head not set correctly!');}"
- name: Verify default Push Workflow
if: ${{ github.event_name != 'pull_request' }}
run: |
if git merge-base --is-ancestor $NX_BASE HEAD; then
BASE_SHA=$NX_BASE;
else
BASE_SHA="";
fi
HEAD_SHA=$(echo $(git rev-parse HEAD))
node -e "if(process.env.NX_BASE == '${BASE_SHA}') console.log('Base set correctly'); else { throw new Error('Base not set correctly!');}"
node -e "if(process.env.NX_HEAD == '${HEAD_SHA}') console.log('Head set correctly'); else { throw new Error('Head not set correctly!');}"