-
Notifications
You must be signed in to change notification settings - Fork 218
/
Copy pathaction.yml
158 lines (155 loc) · 5.69 KB
/
action.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
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
name: Agoric SDK restore Node.js build
description: 'Set up Node.js environment and restore cached built files'
inputs:
node-version:
description: 'The version of Node.js to use'
required: true
path:
description: 'The relative path to the agoric-sdk directory'
required: false
default: '.'
keep-endo:
description: 'Keep Endo repository after installing from it'
required: false
default: 'false'
xsnap-random-init:
description: Build xsnap binary with random memory init
required: false
default: '0'
outputs:
endo-branch:
description: 'The branch of Endo used (NOPE if no override)'
value: ${{ steps.endo-branch.outputs.result }}
runs:
using: composite
steps:
- name: set default environment variables
run: echo ESM_DISABLE_CACHE=true >> $GITHUB_ENV
shell: bash
- uses: actions/checkout@v3
with:
clean: false
submodules: 'true'
persist-credentials: false
path: ${{ inputs.path }}
# Select a branch on Endo to test against by adding text to the body of the
# pull request. For example: #endo-branch: some-pr-branch
# The default is '*NOPE*' to indicate not to check out Endo, just use
# the published NPM packages.
- name: Get the appropriate Endo branch
id: endo-branch
uses: actions/github-script@v6
with:
result-encoding: string
script: |-
let branch = 'NOPE';
if (context.eventName === 'schedule') {
branch = 'master';
} else if (context.payload.pull_request) {
const { body } = context.payload.pull_request;
const regex = /^\#endo-branch:\s+(\S+)/m;
const result = regex.exec(body);
if (result) {
branch = result[1];
}
}
console.log(branch);
return branch;
- name: check out Endo if necessary
id: endo-checkout
uses: actions/checkout@v3
with:
repository: agoric/endo
path: ./replacement-endo
ref: ${{ steps.endo-branch.outputs.result }}
clean: 'false'
submodules: 'true'
persist-credentials: false
if: steps.endo-branch.outputs.result != 'NOPE'
- name: Move Endo checkout outside the working directory
id: endo-sha
run: |-
set -e
if test -e ./replacement-endo; then
mv ./replacement-endo ~/endo
echo "sha=$(cd ~/endo && git rev-parse HEAD)" >> $GITHUB_OUTPUT
else
echo "sha=NOPE" >> $GITHUB_OUTPUT
fi
shell: bash
- name: merge endo integration branch
id: endo-integration-merge
run: |-
set -e
git ls-remote --exit-code --heads origin "refs/heads/integration-endo-${{ steps.endo-branch.outputs.result }}" || exit 0
git fetch --unshallow origin integration-endo-${{ steps.endo-branch.outputs.result }}
git config user.name github-actions
git config user.email github-actions@github.com
git merge --commit --no-edit origin/integration-endo-${{ steps.endo-branch.outputs.result }}
shell: bash
working-directory: ${{ inputs.path }}
if: steps.endo-branch.outputs.result != 'NOPE'
- name: Reconfigure git to use HTTP authentication
run: git config --global url."https://github.com/".insteadOf ssh://git@github.com/
shell: bash
- uses: actions/setup-node@v3
with:
node-version: ${{ inputs.node-version }}
cache: yarn
cache-dependency-path: ${{ inputs.path }}/yarn.lock
- uses: kenchan0130/actions-system-info@master
id: system-info
- name: restore built files
id: built
uses: actions/cache@v3
with:
path: ${{ inputs.path }}
key: ${{ runner.os }}-${{ runner.arch }}-${{ steps.system-info.outputs.release }}-node-${{ inputs.node-version }}-built-${{ inputs.xsnap-random-init }}-${{ github.sha }}-${{ steps.endo-sha.outputs.sha }}
# This and the git diff below are to detect if `yarn install` results in a
# change to the lock file.
- name: yarn install
working-directory: ${{ inputs.path }}
run: |-
set -e
if test "${{ inputs.xsnap-random-init }}" != 0 && test -d /etc/apt; then
# Need libbsd-dev, as it's referenced in xsnapPlatform.h
sudo apt-get update
sudo apt-get install libbsd-dev
fi
# Replace the Endo packages with the ones built from the checked-out branch.
if test -e ~/endo; then
scripts/get-packed-versions.sh ~/endo | scripts/resolve-versions.sh
fi
yarn install
mkdir -p node_modules/.cache/agoric
date > node_modules/.cache/agoric/yarn-installed
if test -e ~/endo; then
# Stage the redirected `yarn install` consequences.
git add package.json yarn.lock
${{ inputs.keep-endo }} || rm -rf ~/endo
fi
shell: bash
if: steps.built.outputs.cache-hit != 'true'
- name: yarn build
working-directory: ${{ inputs.path }}
run: |-
set -e
yarn build
mkdir -p node_modules/.cache/agoric
date > node_modules/.cache/agoric/yarn-built
shell: bash
if: steps.built.outputs.cache-hit != 'true'
env:
XSNAP_RANDOM_INIT: ${{ inputs.xsnap-random-init }}
- name: git dirty check
working-directory: ${{ inputs.path }}
run: |-
set -x
# In case of Endo override, ignore matching index and worktree.
# (First column is non-space, second column is space, followed by separator.)
if [ -n "$(git status --porcelain | grep -Eve '^[^ ] '; true)" ]; then
git status
echo "Unexpected dirty git status" 1>&2
exit 1
fi
shell: bash