[Stacked] Print getting started guides in CI #983
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |