-
Notifications
You must be signed in to change notification settings - Fork 10
166 lines (157 loc) · 6.19 KB
/
ci.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
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
155
156
157
158
159
160
161
162
163
164
165
166
name: CI
on:
push:
branches:
- main
pull_request:
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
jobs:
lint:
name: Rust Code Linting
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Update Rust toolchain
run: rustup update
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Clippy
run: cargo clippy --all-targets --locked -- --deny warnings
- name: rustfmt
run: cargo fmt -- --check
unit-test:
name: Unit Tests
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Update Rust toolchain
run: rustup update
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Run unit tests
run: cargo test --locked
integration-test:
name: Integration Tests (${{ matrix.buildpack-directory }}, ${{matrix.builder}}, ${{matrix.arch}})
runs-on: ${{ matrix.arch == 'arm64' && 'pub-hk-ubuntu-24.04-arm-large' || 'pub-hk-ubuntu-24.04-large' }}
strategy:
fail-fast: false
matrix:
builder: [ "builder:24", "builder:22", "builder:20" ]
arch: [ "amd64", "arm64" ]
buildpack-directory: [ "buildpacks/gradle", "buildpacks/jvm", "buildpacks/jvm-function-invoker", "buildpacks/maven", "buildpacks/sbt" ]
exclude:
- builder: "builder:22"
arch: "arm64"
- builder: "builder:20"
arch: "arm64"
- buildpack-directory: "buildpacks/jvm-function-invoker"
builder: "builder:20"
- buildpack-directory: "buildpacks/jvm-function-invoker"
builder: "builder:24"
env:
INTEGRATION_TEST_BUILDER: heroku/${{ matrix.builder }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Install musl-tools
run: sudo apt-get install -y --no-install-recommends musl-tools
- name: Update Rust toolchain
run: rustup update
- name: Install Rust linux-musl target
run: rustup target add ${{ matrix.arch == 'arm64' && 'aarch64-unknown-linux-musl' || 'x86_64-unknown-linux-musl' }}
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Install Pack CLI
uses: buildpacks/github-actions/[email protected]
# The images are pulled up front to prevent duplicate pulls due to the tests being run concurrently.
- name: Pull builder image
run: docker pull ${{ env.INTEGRATION_TEST_BUILDER }}
- name: Pull run image
# Using `docker inspect` rather than `pack builder inspect` since the latter makes
# additional requests to Docker Hub even when the image is available locally.
run: |
RUN_IMAGE=$(
docker inspect --format='{{index .Config.Labels "io.buildpacks.builder.metadata"}}' '${{ env.INTEGRATION_TEST_BUILDER }}' \
| jq --exit-status --raw-output '.stack.runImage.image'
)
docker pull "${RUN_IMAGE}"
- name: Run integration tests
working-directory: ${{ matrix.buildpack-directory }}
# Runs only tests annotated with the `ignore` attribute (which in this repo, are the integration tests).
run: cargo test --locked -- --ignored --test-threads 16
print-pack-getting-started-output:
runs-on: ${{ matrix.target == 'aarch64-unknown-linux-musl' && 'pub-hk-ubuntu-24.04-arm-medium' || 'ubuntu-24.04' }}
strategy:
matrix:
target: ["aarch64-unknown-linux-musl", "x86_64-unknown-linux-musl"]
guide: ["heroku/java-getting-started", "heroku/gradle-getting-started", "heroku/scala-getting-started"]
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Install musl-tools
run: sudo apt-get install -y --no-install-recommends musl-tools
- name: Update Rust toolchain
run: rustup update
- name: Install Rust linux-musl target
run: rustup target add ${{ matrix.target }}
- name: Rust Cache
uses: Swatinem/[email protected]
- name: Install Pack CLI
uses: buildpacks/github-actions/[email protected]
- name: Pull builder and run images
run: |
docker pull "heroku/builder:24"
docker pull "heroku/heroku:24"
- name: Clone getting started guide
uses: actions/checkout@v4
with:
repository: ${{ matrix.guide }}
path: tmp/guide
- name: Install libcnb-cargo for `cargo libcnb package` command
run: cargo install libcnb-cargo
- name: Compile buildpack
run: cargo libcnb package --target ${{ matrix.target }}
- name: "PRINT: Getting started guide output"
run: |
set -euo pipefail
PACK_CMD="pack build my-image --force-color --builder heroku/builder:24 --trust-extra-buildpacks --path tmp/guide --pull-policy never "
case "${{ matrix.guide }}" in
"heroku/java-getting-started")
PACK_CMD+=" --buildpack packaged/${{ matrix.target }}/debug/heroku_jvm "
PACK_CMD+=" --buildpack packaged/${{ matrix.target }}/debug/heroku_java "
PACK_CMD+=" --buildpack packaged/${{ matrix.target }}/debug/heroku_maven "
;;
"heroku/gradle-getting-started")
PACK_CMD+=" --buildpack packaged/${{ matrix.target }}/debug/heroku_jvm "
PACK_CMD+=" --buildpack packaged/${{ matrix.target }}/debug/heroku_gradle "
;;
"heroku/scala-getting-started")
PACK_CMD+=" --buildpack packaged/${{ matrix.target }}/debug/heroku_jvm "
PACK_CMD+=" --buildpack packaged/${{ matrix.target }}/debug/heroku_sbt "
PACK_CMD+=" --buildpack packaged/${{ matrix.target }}/debug/heroku_scala "
;;
*)
echo "Unknown guide: ${{ matrix.guide }}"
exit 1
;;
esac
echo "Running command: $PACK_CMD"
bash -c "$PACK_CMD"
echo ""
echo "With CACHE example"
echo ""
bash -c "$PACK_CMD"