-
Notifications
You must be signed in to change notification settings - Fork 18
125 lines (118 loc) · 4.05 KB
/
test.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
name: Continuous Integration
on:
pull_request:
branches: [master]
push:
branches: [master]
jobs:
api-docs:
name: API Docs
runs-on: ubuntu-latest
strategy:
matrix:
project: [chisel3]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Scala
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '8'
cache: 'sbt'
- name: Calculate API Docs Cache Key
id: calc-key
run: |
KEY=$(make --always-make --dry-run apis-${{ matrix.project }} | sha256sum | awk '{print $1}')
echo "::set-output name=cache_key::${KEY}"
- name: Cache API Docs
uses: actions/cache@v3
with:
path: build/api/${{ matrix.project }}
key: ${{ runner.os }}-${{ matrix.project }}-${{ steps.calc-key.outputs.cache_key }}
# On miss, still start from previous value for incremental rebuild
restore-keys: |
${{ runner.os }}-${{ matrix.project }}
- name: ${{ matrix.project }} APIs
run: make apis-${{ matrix.project }}
- name: Tar build artifacts
run: tar zcf build/api/${{ matrix.project }}.tar.gz build/api/${{ matrix.project }}
- name: Share API Docs
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.project }}-api-docs
path: build/api/${{ matrix.project }}.tar.gz
website:
name: Build & Deploy Website
needs: [api-docs]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Scala
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '8'
cache: 'sbt'
- name: Install CIRCT
uses: ./.github/workflows/install-circt
- name: Setup Ruby
uses: actions/setup-ruby@v1
- name: Setup Jekyll
run: |
gem install jekyll -v 4.2.0
gem install jekyll-redirect-from
- name: Download all built API docs
uses: actions/download-artifact@v3
with:
path: artifacts
- name: Untar build artifacts
run: for f in $(find artifacts -name "*.tar.gz"); do tar zxf "$f"; done
- name: Fetch submodules
run: git submodule update --init --recursive
- name: Build the microsite
run: make
- name: Deploy to GitHub Pages
if: github.event_name == 'push'
uses: JamesIves/[email protected]
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
FOLDER: docs/target/site
# Sentinel job to simplify how we specify which checks need to pass in branch
# protection. This job checks that all jobs were successful.
#
# When adding new jobs, please add them to `needs` below
check-tests:
name: "check tests"
needs: [api-docs, website]
runs-on: ubuntu-20.04
if: success() # only run if all tests have passed
outputs:
success: ${{ steps.setoutput.outputs.success }}
steps:
- id: setoutput
run: echo "success=true" >> $GITHUB_OUTPUT
# Related to check-tests above, this job _always_ runs (even if tests fail
# and thus check-steps is skipped). This two sentinel job approach avoids an
# issue where failing tests causes a single sentinel job to be skipped which
# counts as passing for purposes of branch protection.
#
# See: https://brunoscheufler.com/blog/2022-04-09-the-required-github-status-check-that-wasnt
all_tests_passed:
name: "all tests passed"
runs-on: ubuntu-20.04
if: always() # Always run so that we never skip this check
needs: check-tests
# Pass only if check-tests set its output value
steps:
- run: |
PASSED="${{ needs.check-tests.outputs.success }}"
if [[ $PASSED == "true" ]]; then
echo "### All tests passed! :rocket:" >> $GITHUB_STEP_SUMMARY
exit 0
else
echo "### One or more tests FAILED! :bangbang:" >> $GITHUB_STEP_SUMMARY
exit 1
fi