-
Notifications
You must be signed in to change notification settings - Fork 6
115 lines (97 loc) · 3.35 KB
/
run-checks-github-runners.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
name: Run checks
on:
push:
branches: [main]
pull_request:
branches: [main]
# Run at 4am PT each day.
schedule:
- cron: "0 11 * * *"
# Allow manual trigger.
workflow_dispatch:
env:
REGISTRY: ghcr.io
# Can't use ${{ env.REGISTRY }} here, but would like to, so that we' don't
# repeat ghcr.io.
IMAGE_TAG: ghcr.io/${{ github.repository }}:sha-${{ github.sha }}
jobs:
# Job which cleans up GitHub Actions workspace. This is only needed when
# running on self-hosted runners.
#
# TODO(@gussmith23) It would be nice if this wasn't necessary. We could use
# this: https://docs.github.com/en/actions/hosting-your-own-runners/running-scripts-before-or-after-a-job
cleaner:
runs-on: self-hosted
steps:
- name: Clean up previous runs
run: rm -rf "${{ github.workspace }}"
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: true
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# If we want to do this more cleanly, we can use metadata-action.
# - name: Extract metadata (tags, labels) for Docker
# id: meta
# uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
# with:
# images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Docker Setup Buildx
uses: docker/setup-buildx-action@v2
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ env.IMAGE_TAG }}
cache-to: type=gha,mode=max
cache-from: type=gha
# This can be run on ubuntu-latest (i.e., on GitHub's provided runners), but
# it will be much slower. Specifically, our end-to-end tests using Verilator
# take advantage of the many threads on our machines, whereas the GitHub
# machines only have two threads.
#
# Perhaps we should run this on both?
run-tests:
runs-on: self-hosted
needs: [build-and-push-image, cleaner]
steps:
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull image
run: docker pull ${{ env.IMAGE_TAG }}
- name: Run tests
run: docker run ${{ env.IMAGE_TAG }} bash run-tests.sh
check-format:
runs-on: ubuntu-latest
needs: build-and-push-image
steps:
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull image
run: docker pull ${{ env.IMAGE_TAG }}
- name: Racket format check
run: |
docker run ${{ env.IMAGE_TAG }} \
bash -c 'raco fmt -i racket/*.rkt && git diff && [ -z "$(git status --porcelain)" ]'
- name: Rust format check
run: docker run ${{ env.IMAGE_TAG }} cargo fmt --manifest-path ./rust/Cargo.toml -- --check