2022-12-31 17:01:07 -07:00
|
|
|
name: Build
|
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
push:
|
2023-05-06 21:25:01 -07:00
|
|
|
env:
|
|
|
|
REGISTRY: ghcr.io
|
2024-09-11 09:59:49 -04:00
|
|
|
IMAGE_NAME: ghcr.io/${{ github.repository }}
|
2022-12-31 17:01:07 -07:00
|
|
|
jobs:
|
|
|
|
tests:
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
os:
|
|
|
|
- ubuntu-latest
|
2024-07-09 12:25:36 -04:00
|
|
|
- macos-latest
|
2024-08-19 12:16:33 -04:00
|
|
|
nix:
|
|
|
|
- "2.20"
|
|
|
|
- "2.24"
|
|
|
|
- "default"
|
2022-12-31 17:01:07 -07:00
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
steps:
|
2024-09-11 09:59:49 -04:00
|
|
|
- uses: actions/checkout@v4.1.7
|
2022-12-31 17:01:07 -07:00
|
|
|
|
2024-08-30 12:32:10 -04:00
|
|
|
- name: Install current Bash on macOS
|
|
|
|
if: runner.os == 'macOS'
|
|
|
|
run: |
|
|
|
|
command -v brew && brew install bash || true
|
|
|
|
|
2024-09-11 09:59:49 -04:00
|
|
|
- uses: DeterminateSystems/nix-installer-action@v14
|
2023-01-08 00:57:22 -07:00
|
|
|
continue-on-error: true # Self-hosted runners already have Nix installed
|
2023-01-02 22:12:56 -07:00
|
|
|
|
|
|
|
- name: Install Attic
|
2023-01-08 00:57:22 -07:00
|
|
|
run: |
|
|
|
|
if ! command -v attic &> /dev/null; then
|
|
|
|
./.github/install-attic-ci.sh
|
|
|
|
fi
|
2023-01-02 22:12:56 -07:00
|
|
|
|
|
|
|
- name: Configure Attic
|
2024-09-11 09:59:49 -04:00
|
|
|
continue-on-error: true
|
2023-01-02 22:12:56 -07:00
|
|
|
run: |
|
2023-01-08 00:57:22 -07:00
|
|
|
: "${ATTIC_SERVER:=https://staging.attic.rs/}"
|
|
|
|
: "${ATTIC_CACHE:=attic-ci}"
|
|
|
|
echo ATTIC_CACHE=$ATTIC_CACHE >>$GITHUB_ENV
|
2023-01-02 22:12:56 -07:00
|
|
|
export PATH=$HOME/.nix-profile/bin:$PATH # FIXME
|
2023-01-08 00:57:22 -07:00
|
|
|
attic login --set-default ci "$ATTIC_SERVER" "$ATTIC_TOKEN"
|
|
|
|
attic use "$ATTIC_CACHE"
|
2023-01-02 22:12:56 -07:00
|
|
|
env:
|
2023-01-08 00:57:22 -07:00
|
|
|
ATTIC_SERVER: ${{ secrets.ATTIC_SERVER }}
|
|
|
|
ATTIC_CACHE: ${{ secrets.ATTIC_CACHE }}
|
2023-01-02 22:12:56 -07:00
|
|
|
ATTIC_TOKEN: ${{ secrets.ATTIC_TOKEN }}
|
2022-12-31 17:01:07 -07:00
|
|
|
|
2024-08-30 12:32:10 -04:00
|
|
|
- name: Cache dev shell
|
2023-01-02 07:46:12 -07:00
|
|
|
run: |
|
2024-08-30 12:32:10 -04:00
|
|
|
.ci/cache-shell.sh
|
2023-01-02 22:12:56 -07:00
|
|
|
system=$(nix-instantiate --eval -E 'builtins.currentSystem')
|
|
|
|
echo system=$system >>$GITHUB_ENV
|
2024-08-30 12:32:10 -04:00
|
|
|
|
2024-08-30 12:32:10 -04:00
|
|
|
- name: Run unit tests
|
2024-08-30 12:32:10 -04:00
|
|
|
run: |
|
2024-08-30 12:32:10 -04:00
|
|
|
.ci/run just ci-unit-tests ${{ matrix.nix }}
|
2023-01-02 22:12:56 -07:00
|
|
|
|
2024-08-19 14:49:56 -04:00
|
|
|
- name: Build WebAssembly crates
|
|
|
|
if: runner.os == 'Linux'
|
|
|
|
run: |
|
2024-08-30 12:32:10 -04:00
|
|
|
.ci/run just ci-build-wasm
|
2024-08-19 14:49:56 -04:00
|
|
|
|
2023-01-02 22:12:56 -07:00
|
|
|
# TODO: Just take a diff of the list of store paths, also abstract all of this out
|
|
|
|
- name: Push build artifacts
|
|
|
|
run: |
|
|
|
|
export PATH=$HOME/.nix-profile/bin:$PATH # FIXME
|
|
|
|
if [ -n "$ATTIC_TOKEN" ]; then
|
2024-08-19 12:16:33 -04:00
|
|
|
nix build --no-link --print-out-paths -L \
|
|
|
|
.#internalMatrix."$system".\"${{ matrix.nix }}\".attic-tests \
|
|
|
|
.#internalMatrix."$system".\"${{ matrix.nix }}\".cargoArtifacts \
|
|
|
|
| xargs attic push "ci:$ATTIC_CACHE"
|
2023-01-02 22:12:56 -07:00
|
|
|
fi
|
2024-09-11 09:59:49 -04:00
|
|
|
|
|
|
|
image:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
if: github.event_name == 'push'
|
|
|
|
needs:
|
|
|
|
- tests
|
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
packages: write
|
|
|
|
steps:
|
2024-09-11 09:59:49 -04:00
|
|
|
- uses: actions/checkout@v4.1.7
|
2024-09-11 09:59:49 -04:00
|
|
|
|
|
|
|
- name: Install current Bash on macOS
|
|
|
|
if: runner.os == 'macOS'
|
|
|
|
run: |
|
|
|
|
command -v brew && brew install bash || true
|
|
|
|
|
2024-09-11 09:59:49 -04:00
|
|
|
- uses: DeterminateSystems/nix-installer-action@v14
|
2024-09-11 09:59:49 -04:00
|
|
|
continue-on-error: true # Self-hosted runners already have Nix installed
|
|
|
|
|
|
|
|
- name: Install Attic
|
|
|
|
run: |
|
|
|
|
if ! command -v attic &> /dev/null; then
|
|
|
|
./.github/install-attic-ci.sh
|
|
|
|
fi
|
|
|
|
|
|
|
|
- name: Configure Attic
|
|
|
|
continue-on-error: true
|
|
|
|
run: |
|
|
|
|
: "${ATTIC_SERVER:=https://staging.attic.rs/}"
|
|
|
|
: "${ATTIC_CACHE:=attic-ci}"
|
|
|
|
echo ATTIC_CACHE=$ATTIC_CACHE >>$GITHUB_ENV
|
|
|
|
export PATH=$HOME/.nix-profile/bin:$PATH # FIXME
|
|
|
|
attic login --set-default ci "$ATTIC_SERVER" "$ATTIC_TOKEN"
|
|
|
|
attic use "$ATTIC_CACHE"
|
|
|
|
env:
|
|
|
|
ATTIC_SERVER: ${{ secrets.ATTIC_SERVER }}
|
|
|
|
ATTIC_CACHE: ${{ secrets.ATTIC_CACHE }}
|
|
|
|
ATTIC_TOKEN: ${{ secrets.ATTIC_TOKEN }}
|
|
|
|
|
|
|
|
- name: Cache dev shell
|
|
|
|
run: |
|
|
|
|
.ci/cache-shell.sh
|
|
|
|
system=$(nix-instantiate --eval -E 'builtins.currentSystem')
|
|
|
|
echo system=$system >>$GITHUB_ENV
|
|
|
|
|
2023-05-06 21:25:01 -07:00
|
|
|
- name: Log in to the Container registry
|
2024-09-11 09:59:49 -04:00
|
|
|
uses: docker/login-action@v3.3.0
|
2023-05-06 21:25:01 -07:00
|
|
|
with:
|
|
|
|
registry: ${{ env.REGISTRY }}
|
|
|
|
username: ${{ github.actor }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
2024-09-11 09:59:49 -04:00
|
|
|
- name: Build and push container images
|
2023-05-06 21:25:01 -07:00
|
|
|
continue-on-error: true
|
|
|
|
run: |
|
2024-09-11 09:59:49 -04:00
|
|
|
declare -a tags
|
|
|
|
tags+=("${{ github.sha }}")
|
|
|
|
|
|
|
|
branch=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
|
|
|
|
if [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
|
|
|
|
tags+=("$(echo $branch | sed -e 's/^v//')")
|
|
|
|
else
|
|
|
|
tags+=("${branch}")
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$branch" == "${{ github.event.repository.default_branch }}" ]; then
|
|
|
|
tags+=("latest")
|
|
|
|
fi
|
|
|
|
|
|
|
|
>&2 echo "Image: ${IMAGE_NAME}"
|
|
|
|
>&2 echo "Tags: ${tags[@]}"
|
|
|
|
|
|
|
|
.ci/run just ci-build-and-push-images "${IMAGE_NAME}" "${tags[@]}"
|
|
|
|
|
|
|
|
# TODO: Just take a diff of the list of store paths, also abstract all of this out
|
|
|
|
- name: Push build artifacts
|
|
|
|
run: |
|
|
|
|
export PATH=$HOME/.nix-profile/bin:$PATH # FIXME
|
|
|
|
if [ -n "$ATTIC_TOKEN" ]; then
|
|
|
|
nix build --no-link --print-out-paths -L \
|
|
|
|
.#attic-server-image \
|
|
|
|
.#attic-server-image-aarch64 \
|
|
|
|
| xargs attic push "ci:$ATTIC_CACHE"
|
2023-05-06 21:25:01 -07:00
|
|
|
fi
|