-
-
Notifications
You must be signed in to change notification settings - Fork 2
154 lines (132 loc) · 6.04 KB
/
ci.yaml
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
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
strategy:
matrix:
scaffold-version:
- v0.3.0
preset:
- kitchen-sink
- java
- js
- go
- py
- cpp
- rust
- minimal
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bazel-contrib/[email protected]
with:
bazelisk-cache: true
repository-cache: true
- uses: jaxxstorm/action-install-gh-release@cd6b2b78ad38bdd294341cda064ec0692b06215b # v1.14.0
with:
repo: hay-kot/scaffold
tag: ${{ matrix.scaffold-version }}
- name: setting to always run hooks
if: "${{ matrix.preset != 'minimal' }}"
run: echo "SCAFFOLD_SETTINGS_RUN_HOOKS=always" >> "$GITHUB_ENV"
- name: Scaffold new app
id: scaffold
run: |
scaffold new --preset=${{ matrix.preset }} --no-prompt $GITHUB_WORKSPACE
cd scaffold_test*
git init
git add .
git config user.email "[email protected]"
git config user.name "No One"
git commit -a -m "initial commit"
echo "dir=$PWD" >> $GITHUB_OUTPUT
- run: bazel test ...
working-directory: "${{ steps.scaffold.outputs.dir }}"
- run: bazel run format
working-directory: "${{ steps.scaffold.outputs.dir }}"
if: "${{ matrix.preset != 'minimal' }}"
- name: format made no changes
working-directory: "${{ steps.scaffold.outputs.dir }}"
run: git diff --exit-code
- name: Tools smoke test
working-directory: "${{ steps.scaffold.outputs.dir }}"
if: "${{ matrix.preset == 'kitchen-sink' }}"
run: |
./tools/copier --help
./tools/yq --help
- name: Java smoke test
working-directory: "${{ steps.scaffold.outputs.dir }}"
if: "${{ matrix.preset == 'java' }}"
run: |
mkdir src
>src/Demo.java echo -e 'class Demo { public static void main(String[] args) { System.out.println("Hello from Java");}}'
>src/BUILD.bazel echo -e 'java_binary(name="Demo", srcs=["Demo.java"])'
output="$(bazel run src:Demo)"
[[ "${output}" == "Hello from Java" ]] || { echo >&2 "Wanted output 'Hello from Java' but got '${output}'" ; exit 1 ; }
- name: Python smoke test
working-directory: "${{ steps.scaffold.outputs.dir }}"
if: "${{ matrix.preset == 'py' }}"
run: |
mkdir app
>app/__main__.py echo -e 'import requests\nprint(requests.get("https://api.github.com").text)'
>app/app_test.py echo -e 'def test_bad():\n assert 1 == 2'
sed -i 's/dependencies = \[/dependencies = ["requests",/' pyproject.toml
./tools/repin
bazel run //app:app_bin
- name: Python test that fails
continue-on-error: true # for some reason `bazel test || true` still failing.
run: bazel test //app:app_test
working-directory: "${{ steps.scaffold.outputs.dir }}"
if: "${{ matrix.preset == 'py' }}"
- name: Check failure is expected
working-directory: "${{ steps.scaffold.outputs.dir }}"
if: "${{ matrix.preset == 'py' }}"
run: grep "FAILED app/app_test.py::test_bad - assert 1 == 2" $(bazel info bazel-testlogs)/app/app_test/test.log
- name: Go smoke test
working-directory: "${{ steps.scaffold.outputs.dir }}"
if: "${{ matrix.preset == 'go' }}"
run: ./tools/go mod tidy
- name: JS smoke test
working-directory: "${{ steps.scaffold.outputs.dir }}"
if: "${{ matrix.preset == 'js' }}"
run: ./tools/pnpm list
- name: Rust smoke test
working-directory: "${{ steps.scaffold.outputs.dir }}"
if: "${{ matrix.preset == 'rust' }}"
run: |
mkdir -p hello_world/src
cat >hello_world/BUILD.bazel <<EOF
load("@rules_rust//rust:defs.bzl", "rust_binary")
rust_binary(
name = "hello_world",
srcs = ["src/main.rs"],
)
EOF
cat >hello_world/src/main.rs <<EOF
fn main() { println!("Hello from Rust"); }
EOF
output="$(bazel run //hello_world)"
[[ "${output}" == "Hello from Rust" ]] || { echo >&2 "Wanted output 'Hello from Rust' but got '${output}'" ; exit 1 ; }
- run: bazel lint ...
working-directory: "${{ steps.scaffold.outputs.dir }}"
# For branch protection settings, this job provides a "stable" name that can be used to gate PR merges
# on "all matrix jobs were successful".
conclusion:
needs: test
runs-on: ubuntu-latest
if: always()
steps:
- uses: technote-space/workflow-conclusion-action@45ce8e0eb155657ab8ccf346ade734257fd196a5 # v3.0.3
# Note: possible conclusion values:
# https://github.com/technote-space/workflow-conclusion-action/blob/main/src/constant.ts
- name: report success
if: ${{ env.WORKFLOW_CONCLUSION == 'success' }}
working-directory: /tmp
run: echo ${{ env.WORKFLOW_CONCLUSION }} && exit 0
- name: report failure
if: ${{ env.WORKFLOW_CONCLUSION == 'failure' }}
working-directory: /tmp
run: echo ${{ env.WORKFLOW_CONCLUSION }} && exit 1