diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..8a48d9f --- /dev/null +++ b/.github/workflows/build.yaml @@ -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 }} + diff --git a/.github/workflows/nvidia-test.yml b/.github/workflows/nvidia-test.yml index f7d0bb0..616b7d4 100644 --- a/.github/workflows/nvidia-test.yml +++ b/.github/workflows/nvidia-test.yml @@ -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: @@ -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 diff --git a/.github/workflows/smoke-test.yml b/.github/workflows/smoke-test.yml index b8a69ad..95ec371 100644 --- a/.github/workflows/smoke-test.yml +++ b/.github/workflows/smoke-test.yml @@ -1,8 +1,10 @@ name: Smoke Test on: - pull_request: - push: + workflow_run: + workflows: ["Build"] + types: + - completed defaults: run: @@ -10,24 +12,18 @@ defaults: 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: | @@ -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 || :