[ci] add workflow for testing docker #46
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: Build Docker Image | |
# Cancel the current workflow when new commit pushed | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number }} | |
cancel-in-progress: true | |
# Release on any git tag | |
on: | |
push: | |
tags: ['*'] | |
paths: | |
- .github/workflows/release.yml | |
- nix/t1/release/docker-image.nix | |
jobs: | |
build: | |
runs-on: [self-hosted, linux, nixos] | |
permissions: | |
contents: read | |
packages: write | |
attestations: write | |
id-token: write | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
- blastoise | |
top: | |
- t1emu | |
- t1rocketemu | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
# Checkout the triggered tag name | |
ref: ${{ github.ref_name }} | |
- name: Build docker image file | |
env: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
set -o pipefail | |
set -o errexit | |
export PATH="$(nix build '.#skopeo.out' --print-out-paths --no-link)/bin:$PATH" | |
export PATH="$(nix build '.#gzip.out' --print-out-paths --no-link)/bin:$PATH" | |
# skopeo need /run/containers to write auth.json file, lets workaround this behavior. | |
export REGISTRY_AUTH_FILE=$(mktemp -d)/auth.json | |
closure="$(nix build -L '.#t1.${{ matrix.config }}.${{ matrix.top }}.docker-image' --no-link --print-out-paths --impure)" | |
skopeo --insecure-policy login --username "$username" --password "$password" "$registry" | |
"$closure" \ | |
| gzip --fast \ | |
| skopeo --insecure-policy copy docker-archive:/dev/stdin \ | |
docker://"$registry"/chipsalliance/t1-${{ matrix.config }}-${{ matrix.top }}:latest | |
test: | |
runs-on: ubuntu-latest | |
needs: [build] | |
strategy: | |
matrix: | |
config: | |
- blastoise | |
top: | |
- t1emu | |
- t1rocketemu | |
steps: | |
- name: Pull and Run tests | |
env: | |
registry: ghcr.io | |
run: | | |
set -o pipefail | |
set -o errexit | |
docker pull "$registry"/chipsalliance/t1-${{ matrix.config }}-${{ matrix.top }}:latest | |
docker run -d --name t1 --rm "$registry"/chipsalliance/t1-${{ matrix.config }}-${{ matrix.top }}:latest /bin/bash -c "sleep inf" | |
dexec() { | |
docker exec t1 /bin/bash -c "$@" | |
} | |
dexec 'cd examples/intrinsic.matmul && t1-cc -T /workspace/share/t1.ld matmul.c /workspace/share/main.S -o matmul.elf' | |
dexec 't1emu-verilated-simulator +t1_elf_file=/workspace/examples/intrinsic.matmul/matmul.elf' |