-
Notifications
You must be signed in to change notification settings - Fork 9
173 lines (159 loc) · 6.4 KB
/
externalNut.yml
File metadata and controls
173 lines (159 loc) · 6.4 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
on:
workflow_call:
secrets:
TESTKIT_AUTH_URL:
required: false
TESTKIT_HUB_USERNAME:
required: false
TESTKIT_JWT_CLIENT_ID:
required: false
TESTKIT_JWT_KEY:
required: false
TESTKIT_HUB_INSTANCE:
required: false
inputs:
# could we get this from pjson?
packageName:
description: 'The npm package that this repository publishes. ex: @salesforce/core'
required: true
type: string
externalProjectGitUrl:
description: 'The url that will be cloned. This contains the NUTs you want to run. Ex: https://github.com/salesforcecli/plugin-user'
type: string
required: true
command:
required: false
type: string
default: yarn test:nuts
description: 'command to execute (ex: yarn test:nuts)'
nodeVersion:
required: false
description: version of node to run tests against. Use things like [lts/-1, lts/*, latest] to avoid hardcoding versions
type: string
default: lts/*
os:
required: false
description: 'runs-on property, ex: ubuntu-latest, windows-latest'
type: string
default: 'ubuntu-latest'
sfdxExecutablePath:
required: false
description: "Path to sfdx executable to be used by NUTs, defaults to ''"
type: string
preBuildCommands:
required: false
description: 'commands to run before the build...for example, to delete known module conflicts'
type: string
default: 'echo "no preBuildCommands passed"'
postBuildCommands:
required: false
description: 'script to run after the build'
type: string
default: 'echo "no postBuildCommands passed"'
preExternalBuildCommands:
required: false
description: 'commands to run before the build of the external repo...for example, to delete known module conflicts'
type: string
default: 'echo "no preExternalBuildCommands passed"'
preSwapCommands:
required: false
description: 'commands to run before ANY modifications happen. For example, changes that modify the lockfile like yarn add or remove need to happen before the action manually swaps the dependency under test'
type: string
default: 'echo "no preSwapCommands passed"'
useCache:
required: false
type: boolean
default: true
attempts:
required: false
type: number
default: 3
branch:
required: false
description: "branch to clone from the repo. Defaults to 'main'"
type: string
default: 'main'
ignoreScripts:
required: false
description: 'if true, will run yarn install --ignore-scripts when building package in node_modules'
type: boolean
default: false
jobs:
external-nut:
name: ${{ inputs.command }}
runs-on: ${{ inputs.os }}
steps:
- name: Configure git longpaths if on Windows
if: ${{ runner.os == 'Windows' }}
run: git config --system core.longpaths true
- uses: actions/setup-node@v4
with:
node-version: ${{ inputs.nodeVersion }}
- uses: salesforcecli/github-workflows/.github/actions/retry@main
name: cli install
with:
max_attempts: ${{ inputs.attempts }}
command: npm install -g @salesforce/cli@nightly shx yarn-deduplicate --omit=dev
timeout_minutes: 20
- uses: salesforcecli/github-workflows/.github/actions/retry@main
name: git clone
with:
max_attempts: 20
command: git clone -b ${{ inputs.branch }} --single-branch ${{ inputs.externalProjectGitUrl }} $(pwd)
timeout_minutes: 20
- name: Cache node modules
if: inputs.useCache
id: cache-nodemodules
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-externalNuts-${{ env.cache-name }}-${{ inputs.externalProjectGitUrl}}-${{ inputs.branch}}-${{ github.sha }}
env:
cache-name: cache-node-modules
- uses: salesforcecli/github-workflows/.github/actions/yarnInstallWithRetries@main
if: ${{ steps.cache-nodemodules.outputs.cache-hit != 'true' }}
- name: Run preSwapCommands
run: ${{ inputs.preSwapCommands }}
if: ${{ steps.cache-nodemodules.outputs.cache-hit != 'true' }}
- name: Swap this dependency for the version on this branch
if: ${{ steps.cache-nodemodules.outputs.cache-hit != 'true' }}
run: |
yarn remove "$INPUTS_PACKAGE_NAME"
yarn add ${{ github.repository }}#${{ github.sha }}
npx yarn-deduplicate
yarn install --network-timeout 600000
env:
INPUTS_PACKAGE_NAME: ${{ inputs.packageName }}
- name: Install/build ${{ inputs.packageName }} in node_modules
if: ${{ steps.cache-nodemodules.outputs.cache-hit != 'true' }}
working-directory: node_modules/${{ inputs.packageName }}
run: |
yarn install --network-timeout 600000 ${{ inputs.ignoreScripts && '--ignore-scripts' || '' }}
${{ inputs.preBuildCommands }}
yarn compile
${{ inputs.postBuildCommands }}
- name: Run preExternalBuildCommands
if: ${{ steps.cache-nodemodules.outputs.cache-hit != 'true' }}
run: ${{ inputs.preExternalBuildCommands }}
- name: Build the external project (where the NUTs are)
run: yarn compile
- name: Set optional sf executable path
if: inputs.sfdxExecutablePath
run: echo "TESTKIT_EXECUTABLE_PATH=$INPUTS_SF_EXECUTABLE_PATH" >> $GITHUB_ENV
env:
INPUTS_SF_EXECUTABLE_PATH: ${{ inputs.sfdxExecutablePath }}
- name: NUTs with ${{ inputs.attempts }} attempts
uses: salesforcecli/github-workflows/.github/actions/retry@main
with:
max_attempts: ${{ inputs.attempts }}
command: ${{ inputs.command }}
retry_on: error
env:
SF_DISABLE_TELEMETRY: true
TESTKIT_AUTH_URL: ${{ secrets.TESTKIT_AUTH_URL }}
TESTKIT_HUB_USERNAME: ${{ secrets.TESTKIT_HUB_USERNAME }}
TESTKIT_HUB_INSTANCE: ${{ secrets.TESTKIT_HUB_INSTANCE }}
TESTKIT_JWT_CLIENT_ID: ${{ secrets.TESTKIT_JWT_CLIENT_ID }}
TESTKIT_JWT_KEY: ${{ secrets.TESTKIT_JWT_KEY }}
TESTKIT_SETUP_RETRIES: 2
DEBUG: ${{ vars.DEBUG }}