Skip to content

Enable User env vars in subprocesses #1026

Enable User env vars in subprocesses

Enable User env vars in subprocesses #1026

Workflow file for this run

name: CI
on:
push:
# Avoid duplicate builds on PRs.
branches:
- main
pull_request:
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
jobs:
lint:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Update Rust toolchain
run: rustup update
- name: Rust Cache
uses: Swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0 # v2.8.0
- name: Clippy
run: cargo clippy --all-targets --locked -- --deny warnings
- name: rustfmt
run: cargo fmt -- --check
unit-test:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Update Rust toolchain
run: rustup update
- name: Rust Cache
uses: Swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0 # v2.8.0
- name: Run unit tests
run: cargo test --locked
unit-test-coverage:
name: Generate test coverage report
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Install nightly Rust toolchain
run: rustup install nightly
- name: Rust Cache
uses: Swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0 # v2.8.0
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@0eee80d37f55e834144deec670972c19e81a85b0 # v2.56.0
with:
tool: cargo-llvm-cov
- name: Run unit tests and generate coverage report
run: cargo +nightly llvm-cov --locked --html
- name: Upload HTML coverage report
uses: actions/upload-artifact@v4
with:
name: "llvm-cov-html-${{github.event.repository.name}}-${{github.sha}}"
path: "target/llvm-cov/html"
if-no-files-found: "error"
integration-test:
name: integration-tests ${{ matrix.builder }} / ${{ matrix.arch }}
runs-on: ${{ matrix.arch == 'arm64' && 'pub-hk-ubuntu-24.04-arm-medium' || 'ubuntu-24.04' }}
strategy:
fail-fast: false
matrix:
arch: ["amd64"]
builder: ["heroku/builder:20", "heroku/builder:22", "heroku/builder:24"]
include:
- arch: "arm64"
builder: "heroku/builder:24"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install musl-tools
run: sudo apt-get install musl-tools -y --no-install-recommends
- 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@98c8021b550208e191a6a3145459bfc9fb29c4c0 # v2.8.0
- name: Install Pack CLI
uses: buildpacks/github-actions/setup-pack@bc04fbfd78e903050bab17a2dcf907e71e3c4afa # v5.9.2
# The images are pulled up front to prevent duplicate pulls due to the tests being run concurrently.
- name: Pull builder image
run: docker pull ${{ matrix.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"}}' '${{ matrix.builder }}' \
| jq --exit-status --raw-output '.stack.runImage.image'
)
docker pull "${RUN_IMAGE}"
- name: Run integration tests
env:
INTEGRATION_TEST_BUILDER: ${{ matrix.builder }}
# 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: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
- 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 x86_64-unknown-linux-musl
- name: Rust Cache
uses: Swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0 # v2.8.0
- name: Install Pack CLI
uses: buildpacks/github-actions/setup-pack@bc04fbfd78e903050bab17a2dcf907e71e3c4afa # v5.9.2
- 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: heroku/go-getting-started
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 x86_64-unknown-linux-musl
- name: "PRINT: Getting started guide output"
run: |
set euo --pipefail
echo "## Getting Started output" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
pack build my-image --force-color --builder heroku/builder:24 --trust-extra-buildpacks --buildpack packaged/x86_64-unknown-linux-musl/debug/heroku_go --path tmp/guide --pull-policy never \
|& tee >(sed -e 's/\x1b\[[0-9;]*m//g' >> $GITHUB_STEP_SUMMARY)
echo '```' >> $GITHUB_STEP_SUMMARY
- name: "PRINT: Cached getting started guide output"
run: |
set -euo pipefail
echo "## Cached Output" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
pack build my-image --force-color --builder heroku/builder:24 --trust-extra-buildpacks --buildpack packaged/x86_64-unknown-linux-musl/debug/heroku_go --path tmp/guide --pull-policy never \
|& tee >(sed -e 's/\x1b\[[0-9;]*m//g' >> $GITHUB_STEP_SUMMARY)
echo '```' >> $GITHUB_STEP_SUMMARY