Skip to content

Commit

Permalink
Change GH workflows to publish the snap to Store for Nvidia testing (#…
Browse files Browse the repository at this point in the history
…170)


* Split the build and test workflows

* Add possibility to run Nvidia tests against the built artifact, by passing a completed workflow run-id

Signed-off-by: Lincoln Wallace <lincoln.wallace@canonical.com>
  • Loading branch information
locnnil authored Aug 26, 2024
1 parent a802807 commit 3dd32f1
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 23 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Build

on:
pull_request:
push:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Build
uses: snapcore/action-build@v1
id: snapcraft
with:
snapcraft-args: snap --output docker_${{ github.run_id}}.snap

- name: Upload
uses: actions/upload-artifact@v4
with:
name: docker_${{ github.run_id}}.snap
path: ${{ steps.snapcraft.outputs.snap }}

25 changes: 19 additions & 6 deletions .github/workflows/nvidia-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ on:
# Manual trigger
workflow_dispatch:
inputs:
snap-channel:
description: 'Docker snap channel'
run_id:
description: 'Run id number'
required: true
type: string
default: 'latest/edge'
type: number

jobs:
test:
Expand All @@ -31,11 +30,25 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Get the artifact
uses: dawidd6/action-download-artifact@v6
with:
workflow: build.yml
name: docker_${{ inputs.run_id }}.snap

- name: Publish to Store
uses: snapcore/action-publish@v1
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_LOGIN }}
with:
snap: docker_${{ inputs.run_id }}.snap
release: latest/edge/runid-${{ inputs.run_id }}

- name: Create Testflinger job queue
run: |
export JOB_QUEUE="${{ matrix.job-queue }}"
export SNAP_CHANNEL="${{ inputs.snap-channel }}"
export SNAP_CHANNEL="latest/edge/runid-${{ inputs.run_id }}"
envsubst '$JOB_QUEUE' \
< $TESTFLINGER_DIR/nvidia-job.yaml \
> $TESTFLINGER_DIR/nvidia-job.temp
Expand Down
33 changes: 16 additions & 17 deletions .github/workflows/smoke-test.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
name: Smoke Test

on:
pull_request:
push:
workflow_run:
workflows: ["Build"]
types:
- completed

defaults:
run:
shell: 'bash -Eeuo pipefail -x {0}'

jobs:
smoke-test:
name: Snapcraft
runs-on: ubuntu-22.04
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- uses: actions/checkout@v2
- name: Checkout code
uses: actions/checkout@v4

- name: Build
# https://github.com/snapcore/action-build/releases
uses: snapcore/action-build@v1
- name: Get the artifact
uses: dawidd6/action-download-artifact@v6
with:
snapcraft-args: snap --output docker.snap

- name: Upload
# TODO the goal of this "if:" condition is to avoid creating artifacts on private forks (and using up all their storage quota), but Tianon couldn't find a clean way to do that so this was the next best thing
if: github.repository == 'docker-snap/docker-snap'
uses: actions/upload-artifact@v2
with:
name: docker.snap
path: docker.snap
workflow: build.yml
name: docker_[0-9]+.snap
name_is_regexp: true

- name: Prep
run: |
Expand All @@ -48,7 +44,10 @@ jobs:
- name: Install
run: |
sudo snap install --dangerous ./docker.snap
# dawidd6/action-download-artifact action creates a directory when the name is given as a RegExp
cd ./docker_*.snap
sudo snap install --dangerous ./docker_*.snap
# it will immediately be failing to start, so let's head that off as quickly as we can
sudo snap stop --disable docker.dockerd
sudo killall dockerd || :
Expand Down

0 comments on commit 3dd32f1

Please sign in to comment.