-
Notifications
You must be signed in to change notification settings - Fork 8
107 lines (98 loc) · 4.04 KB
/
externalCompile.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
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
on:
workflow_call:
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 code you want to compile. Ex: https://github.com/salesforcecli/plugin-user"
type: string
required: true
command:
required: false
type: string
default: yarn compile
description: "command to execute (ex: yarn compile, yarn build)"
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"
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"'
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-build:
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 }}
- name: Git clone
uses: salesforcecli/github-workflows/.github/actions/retry@main
with:
max_attempts: 20
command: git clone -b "$INPUTS_BRANCH" --single-branch "$INPUTS_EXTERNAL_PROJECT_GIT_URL" $(pwd)
timeout_minutes: 20
env:
INPUTS_BRANCH: ${{ inputs.branch }}
INPUTS_EXTERNAL_PROJECT_GIT_URL: ${{ inputs.externalProjectGitUrl }}
- uses: salesforcecli/github-workflows/.github/actions/yarnInstallWithRetries@main
- run: ${{ inputs.preSwapCommands }}
- name: Swap this dependency for the version on this branch
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
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
run: ${{ inputs.preExternalBuildCommands }}
- name: Build the external project (where the NUTs are)
run: ${{ inputs.command }}