-
Notifications
You must be signed in to change notification settings - Fork 129
112 lines (107 loc) · 4.96 KB
/
advance-zed.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
name: Advance Zed
# This type must match the event type from Zed.
# https://help.github.com/en/actions/reference/events-that-trigger-workflows#external-events-repository_dispatch
# These events only trigger on the GitHub default branch (usually main
# or master).
on:
repository_dispatch:
types: [zed-pr-merged]
jobs:
advance-zed:
name: Advance Zed
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04]
timeout-minutes: 60
steps:
# Only one of these should run at a time, and the checkout of brim
# has to be in the "protected section". This will poll every 60s
# forever. It will be timed out based on any change to
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idtimeout-minutes
# It is not possible to time out this step and fail. It's only
# possible to time out this step and continue.
- name: Turnstyle
uses: softprops/turnstyle@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Since we intend to push, we must have a a writable token and
# minimal git config settings to create commits.
- uses: actions/checkout@v3
with:
# ref defaults to github.sha, which is fixed at the time a run
# is triggered. Using github.ref ensures a run that waits in
# the turnstyle action will see any commits pushed by the runs
# that caused it to wait, reducing push failures down below.
ref: ${{ github.ref }}
token: ${{ secrets.ZQ_UPDATE_PAT }}
- run: git config --local user.email 'automation@brimdata.io'
- run: git config --local user.name 'Brim Automation'
# This section gets event information.
- run: jq '.' "${GITHUB_EVENT_PATH}"
- name: process pull request event
id: zed_pr
# $GITHUB_EVENT_PATH is the JSON we posted from Zed.
# Variables for other steps get set as described here:
# https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-output-parameter
#
# body can be multiline and must be escaped as described here:
# https://github.community/t5/GitHub-Actions/set-output-Truncates-Multiline-Strings/m-p/37870
#
# Rewrite bare PR numbers as Zed PRs (https://github.com/brimdata/brim/issues/797)
run: |
sha="$(jq -r '.client_payload.merge_commit_sha' "${GITHUB_EVENT_PATH}")"
echo "sha=$sha" >> $GITHUB_OUTPUT
branch="$(jq -r '.client_payload.branch' "${GITHUB_EVENT_PATH}")"
echo "branch=$branch" >> $GITHUB_OUTPUT
number="$(jq -r '.client_payload.number' "${GITHUB_EVENT_PATH}")"
echo "number=$number" >> $GITHUB_OUTPUT
title="$(jq -r '.client_payload.title' "${GITHUB_EVENT_PATH}")"
title="$(perl -pe 's,(\W+)(#\d+)(\W+),$1brimdata/zed$2$3,g; s,^(#\d+)(\W+),brimdata/zed$1$2,g; s,(\W+)(#\d+),$1brimdata/zed$2,g; s,^(#\d+)$,brimdata/zed$1,g;' <<< "${title}")"
echo "title=$title" >> $GITHUB_OUTPUT
body="$(jq -r '.client_payload.body' "${GITHUB_EVENT_PATH}")"
body="$(perl -pe 's,(\W+)(#\d+)(\W+),$1brimdata/zed$2$3,g; s,^(#\d+)(\W+),brimdata/zed$1$2,g; s,(\W+)(#\d+),$1brimdata/zed$2,g; s,^(#\d+)$,brimdata/zed$1,g;' <<< "${body}")"
body="${body//'%'/'%25'}"
body="${body//$'\n'/'%0A'}"
body="${body//$'\r'/'%0D'}"
echo "body=$body" >> $GITHUB_OUTPUT
url="$(jq -r '.client_payload.url' "${GITHUB_EVENT_PATH}")"
echo "url=$url" >> $GITHUB_OUTPUT
user="$(jq -r '.client_payload.user' "${GITHUB_EVENT_PATH}")"
echo "user=$user" >> $GITHUB_OUTPUT
# This section runs typical CI, with an updated Zed. Most of this
# is no different than the normal CI flow.
- uses: actions/setup-go@v2
with:
go-version: '1.18'
- uses: actions/setup-node@v3
with:
cache: yarn
node-version-file: .node-version
- run: yarn add zed@brimdata/zed#${{ steps.zed_pr.outputs.sha }}
- run: yarn --inline-builds
- run: yarn lint
- run: yarn test
- run: yarn build
- name: End to end tests
id: playwright
uses: GabrielBB/xvfb-action@v1
with:
options: -screen 0 1280x1024x24
run: yarn e2e
env:
DEBUG: pw:api
- uses: actions/upload-artifact@v2
if: failure() && steps.playwright.outcome == 'failure'
with:
name: artifacts-${{ matrix.os }}
path: |
run/playwright-itest
!run/**/SS
- run: git commit -a -m 'upgrade Zed to ${{ github.event.client_payload.merge_commit_sha }}'
# If this push fails because a PR was merged while this job was
# running, you can re-run the failed job via
# https://github.com/brimdata/brim/actions. Or, if you expect
# this workflow to be dispatched again soon, you can simply ignore
# the failure.
- run: git push