name: Course release on: pull_request: workflow_dispatch: push: tags: ['classroom-*'] permissions: contents: read concurrency: group: course-release-${{ github.ref }} cancel-in-progress: false jobs: stage: if: github.event_name != 'push' || github.event.created == true runs-on: ubuntu-24.04 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: Validate course release tag if: github.event_name == 'push' run: | [[ "$GITHUB_REF_NAME" =~ ^classroom-([0-9]{4}\.[0-9]{2}\.[0-9]{2})(\.[1-9][0-9]*)?$ ]] python3 -c 'from datetime import datetime; import sys; datetime.strptime(sys.argv[1], "%Y.%m.%d")' "${BASH_REMATCH[1]}" - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: '22.17.1' package-manager-cache: false - name: Test the student-site smoke checker run: python3 -B -m unittest discover -s containers -p 'test_*.py' - name: Stage this course revision once run: | npm ci --prefix website containers/prepare.sh dist/context test "$(cat dist/context/materials/course-revision.txt)" = "$(git rev-parse HEAD)" tar -czf dist/context.tgz -C dist/context . - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: staged-course path: dist/context.tgz if-no-files-found: error compression-level: 0 overwrite: true retention-days: 7 verify: name: Verify Docker and Apptainer on ${{ matrix.arch }} needs: stage strategy: fail-fast: false matrix: include: - arch: amd64 runner: ubuntu-24.04 launchpad-build: '33866858' deb-sha256: 773464c31c22107e7d814284396a3ca56e440339e806b6febdda5b3670fe81a7 - arch: arm64 runner: ubuntu-24.04-arm launchpad-build: '33866859' deb-sha256: ea0104bb5ae6ea904bd0760f809f2297acf2a76efe92333b61231d69b6b17146 runs-on: ${{ matrix.runner }} env: ARCH: ${{ matrix.arch }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: name: staged-course path: dist - name: Install Apptainer 1.5.5 env: BUILD_ID: ${{ matrix.launchpad-build }} DEB_SHA256: ${{ matrix.deb-sha256 }} working-directory: ${{ runner.temp }} run: | package="apptainer_1.5.5-1~noble_${ARCH}.deb" curl -fsSL --retry 3 --retry-all-errors --retry-delay 5 -o "$package" "https://launchpad.net/~apptainer/+archive/ubuntu/ppa/+build/$BUILD_ID/+files/$package" echo "$DEB_SHA256 $package" | sha256sum -c - sudo apt-get update -qq sudo apt-get install -y "./$package" apptainer --version - name: Build both images from the staged files run: | mkdir -p dist/context dist/tested tar -xzf dist/context.tgz -C dist/context test "$(cat dist/context/materials/course-revision.txt)" = "$(git rev-parse HEAD)" docker buildx build --load --provenance=false -t classroom:tested \ --label "org.opencontainers.image.source=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" \ --label "org.opencontainers.image.revision=$(git rev-parse HEAD)" dist/context (cd dist/context && sudo apptainer build ../tested/classroom.sif classroom.def) - name: Compare student materials and full grading reports run: | python3 containers/verify.py run docker classroom:tested dist/docker.json python3 containers/verify.py run apptainer "$PWD/dist/tested/classroom.sif" dist/apptainer.json python3 containers/verify.py compare dist/apptainer.json dist/docker.json - name: Crawl both student sites through their normal launchers run: bash containers/smoke-release.sh classroom:tested "$PWD/dist/tested/classroom.sif" - name: Save the tested Docker image if: github.event_name == 'push' run: docker save -o dist/tested/docker.tar classroom:tested - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 if: github.event_name == 'push' with: name: tested-${{ matrix.arch }} path: dist/tested compression-level: 1 if-no-files-found: error overwrite: true retention-days: 7 publish: if: github.event_name == 'push' && github.event.created == true && startsWith(github.ref, 'refs/tags/classroom-') needs: verify runs-on: ubuntu-24.04 permissions: contents: write packages: write steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: pattern: tested-* path: dist - name: Install regctl 0.11.7 working-directory: ${{ runner.temp }} run: | curl -fsSL --retry 3 --retry-all-errors --retry-delay 5 -o regctl https://github.com/regclient/regclient/releases/download/v0.11.7/regctl-linux-amd64 echo '3737fbbdd791e04e7a831640b681f3397a376498e80e2ad9b1b2d27296f239bc regctl' | sha256sum -c - sudo install -m 0755 regctl /usr/local/bin/regctl - name: Publish the tested image index and SIFs env: GH_TOKEN: ${{ github.token }} run: bash containers/publish-release.sh