Skip to content

Commit

Permalink
ci: fix the GitHub actions repository_dispatch workflow
Browse files Browse the repository at this point in the history
We switch from using a Go-based GitHub action to using curl directly
because it's significantly quicker.

We also drop the unnecessary requirement on refs having been replicated
to GitHub by fetching from the source directly.

Change-Id: I58487b986aea120ce0e5cd60999103023d4ab389
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/6020
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Marcel van Lohuizen <mpvl@google.com>
  • Loading branch information
myitcv authored and mpvl committed May 13, 2020
1 parent 2b118fb commit 8f1d260
Showing 1 changed file with 26 additions and 45 deletions.
71 changes: 26 additions & 45 deletions .github/workflows/test_dispatch.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,33 @@
name: Test

on: [repository_dispatch]

name: Test
env:
GERRIT_COOKIE: "${{ secrets.gerritCookie }}"
defaults:
run:
shell: bash
jobs:
start:
runs-on: ubuntu-latest
steps:

# Go is required for the cue-sh/trybot action
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.14.x
- name: Write the gitcookies file
run: echo "$GERRIT_COOKIE" > ~/.gitcookies

- name: Update Gerrit CL message with starting message
uses: cue-sh/trybot@latest
with:
mode: start
runID: ${{ github.run_id }}
ref: ${{ github.event.client_payload.ref }}
changeID: ${{ github.event.client_payload.changeID }}
jobStatus: ${{ job.status }}
repo: ${{ github.event.repository.html_url }}
gerritCookie: ${{ secrets.gerritCookie }}
run: >
curl -s -H "Content-Type: application/json" --request POST --data '{"message":"Started the build... see progress at ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}"}' -b ~/.gitcookies https://cue-review.googlesource.com/a/changes/${{ github.event.client_payload.changeID }}/revisions/${{ github.event.client_payload.commit }}/review
test:
needs: start
strategy:
fail-fast: false
matrix:
go-version: [1.13.x, 1.14.x]
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Write the gitcookies file
run: echo "$GERRIT_COOKIE" > ~/.gitcookies

- name: Install Go
uses: actions/setup-go@v2
with:
Expand All @@ -40,6 +36,11 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2

- name: Checkout ref
run: |
git fetch https://cue-review.googlesource.com/cue ${{ github.event.client_payload.ref }}
git checkout FETCH_HEAD
- name: Cache Go modules
uses: actions/cache@v1
with:
Expand All @@ -53,38 +54,18 @@ jobs:
- name: Test with -race
run: go test -race ./...

- name: Update Gerrit CL message with failure message
- name: Post any failures for this matrix entry
if: ${{ failure() }}
uses: cue-sh/trybot@latest
with:
mode: end
runID: ${{ github.run_id }}
ref: ${{ github.event.client_payload.ref }}
changeID: ${{ github.event.client_payload.changeID }}
jobStatus: "failure"
matrixDesc: "${{ runner.os }}-${{ matrix.go-version }}"
repo: ${{ github.event.repository.html_url }}
gerritCookie: ${{ secrets.gerritCookie }}
run: >
curl -s -H "Content-Type: application/json" --request POST --data '{"labels": { "Code-Review": -1 }, "message":"Build failed for ${{ runner.os }}-${{ matrix.go-version }}; see ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }} for more details"}' -b ~/.gitcookies https://cue-review.googlesource.com/a/changes/${{ github.event.client_payload.changeID }}/revisions/${{ github.event.client_payload.commit }}/review
end:
needs: test
runs-on: ubuntu-latest
steps:

# Go is required for the cue-sh/trybot action
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.14.x
- name: Write the gitcookies file
run: echo "$GERRIT_COOKIE" > ~/.gitcookies

- name: Update Gerrit CL message with success message
uses: cue-sh/trybot@latest
with:
mode: end
runID: ${{ github.run_id }}
ref: ${{ github.event.client_payload.ref }}
changeID: ${{ github.event.client_payload.changeID }}
jobStatus: "success"
repo: ${{ github.event.repository.html_url }}
gerritCookie: ${{ secrets.gerritCookie }}

run: >
curl -s -H "Content-Type: application/json" --request POST --data '{"labels": { "Code-Review": 1 }, "message":"Build succeeded for ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}"}' -b ~/.gitcookies https://cue-review.googlesource.com/a/changes/${{ github.event.client_payload.changeID }}/revisions/${{ github.event.client_payload.commit }}/review

0 comments on commit 8f1d260

Please sign in to comment.