|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + branches: [main, morph] |
| 7 | + paths-ignore: |
| 8 | + - .forgejo/workflows/bootstrap.yml |
| 9 | + - pkgs/bits-ci/** |
| 10 | + pull_request: |
| 11 | + branches: [main, morph] |
| 12 | + paths-ignore: |
| 13 | + - .forgejo/workflows/bootstrap.yml |
| 14 | + - pkgs/bits-ci/** |
| 15 | + |
| 16 | +concurrency: |
| 17 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 18 | + cancel-in-progress: true |
| 19 | + |
| 20 | +permissions: |
| 21 | + packages: read |
| 22 | + |
| 23 | +env: |
| 24 | + CI: true |
| 25 | + IMAGE: git.lan.invetica.co.uk/jcf/bits/bits-ci:20260225-9a8b11c |
| 26 | + |
| 27 | +jobs: |
| 28 | + check: |
| 29 | + name: Check |
| 30 | + runs-on: nixos |
| 31 | + container: |
| 32 | + image: ${{ env.IMAGE }} |
| 33 | + credentials: |
| 34 | + username: jcf |
| 35 | + password: ${{ github.token }} |
| 36 | + steps: |
| 37 | + - uses: actions/checkout@v4 |
| 38 | + |
| 39 | + - name: Check |
| 40 | + run: just check |
| 41 | + |
| 42 | + test: |
| 43 | + name: Test |
| 44 | + runs-on: nixos |
| 45 | + container: |
| 46 | + image: ${{ env.IMAGE }} |
| 47 | + credentials: |
| 48 | + username: jcf |
| 49 | + password: ${{ github.token }} |
| 50 | + services: |
| 51 | + postgres: |
| 52 | + image: postgres:17 |
| 53 | + env: |
| 54 | + POSTGRES_USER: bits |
| 55 | + POSTGRES_PASSWORD: please |
| 56 | + POSTGRES_DB: bits_test |
| 57 | + steps: |
| 58 | + - uses: actions/checkout@v4 |
| 59 | + |
| 60 | + - name: Cache Clojure deps |
| 61 | + uses: actions/cache@v4 |
| 62 | + with: |
| 63 | + path: | |
| 64 | + ~/.m2/repository |
| 65 | + ~/.gitlibs |
| 66 | + ~/.deps.clj |
| 67 | + key: maven-${{ hashFiles('deps.edn') }} |
| 68 | + restore-keys: maven- |
| 69 | + |
| 70 | + - name: Wait for PostgreSQL |
| 71 | + run: | |
| 72 | + for i in $(seq 1 30); do |
| 73 | + pg_isready -h postgres -p 5432 -U bits && exit 0 |
| 74 | + sleep 1 |
| 75 | + done |
| 76 | + echo "Postgres failed to start" |
| 77 | + exit 1 |
| 78 | +
|
| 79 | + - name: Generate CSS |
| 80 | + run: tailwindcss --input resources/tailwind.css --output resources/public/app.css |
| 81 | + |
| 82 | + - name: Run tests |
| 83 | + env: |
| 84 | + CLUSTER_KEYSTORE_PASSWORD: correct-horse-battery-staple |
| 85 | + DATABASE_URL: postgres://bits:please@postgres:5432/bits_test |
| 86 | + run: just os=linux-x86_64 test --reporter documentation |
| 87 | + |
| 88 | + build: |
| 89 | + name: Build ${{ matrix.arch }} |
| 90 | + runs-on: nixos |
| 91 | + needs: [check, test] |
| 92 | + if: github.event_name == 'push' |
| 93 | + |
| 94 | + strategy: |
| 95 | + matrix: |
| 96 | + include: |
| 97 | + - arch: amd64 |
| 98 | + output: bits-container-amd64 |
| 99 | + - arch: arm64 |
| 100 | + output: bits-container-arm64 |
| 101 | + |
| 102 | + steps: |
| 103 | + - uses: actions/checkout@v4 |
| 104 | + |
| 105 | + - name: Configure Attic cache |
| 106 | + env: |
| 107 | + ATTIC_TOKEN: ${{ secrets.ATTIC_TOKEN }} |
| 108 | + run: .forgejo/scripts/attic-setup.sh |
| 109 | + |
| 110 | + - name: Build container |
| 111 | + id: build |
| 112 | + run: | |
| 113 | + set -o pipefail |
| 114 | + image_path=$(.forgejo/scripts/build.sh "${{ matrix.output }}" 2>&1 | .forgejo/scripts/filter-devenv.sh | head -1) |
| 115 | + echo "image_path=$image_path" >> "$GITHUB_OUTPUT" |
| 116 | +
|
| 117 | + - name: Push to Attic cache |
| 118 | + run: attic push invetica:invetica "${{ steps.build.outputs.image_path }}" |
| 119 | + |
| 120 | + - name: Load and tag image |
| 121 | + id: tag |
| 122 | + run: .forgejo/scripts/tag-image.sh "${{ steps.build.outputs.image_path }}" "${{ matrix.arch }}" |
| 123 | + |
| 124 | + - name: Push to ghcr.io |
| 125 | + run: | |
| 126 | + echo "${{ secrets.GH_TOKEN }}" | podman login ghcr.io -u jcf --password-stdin |
| 127 | + podman push "${{ steps.tag.outputs.image }}:${{ steps.tag.outputs.version }}-${{ matrix.arch }}" |
| 128 | +
|
| 129 | + outputs: |
| 130 | + version: ${{ steps.tag.outputs.version }} |
| 131 | + image: ${{ steps.tag.outputs.image }} |
| 132 | + |
| 133 | + manifest: |
| 134 | + name: Create manifest |
| 135 | + runs-on: nixos |
| 136 | + needs: [build] |
| 137 | + if: github.event_name == 'push' |
| 138 | + |
| 139 | + steps: |
| 140 | + - name: Login to ghcr.io |
| 141 | + run: echo "${{ secrets.GH_TOKEN }}" | podman login ghcr.io -u jcf --password-stdin |
| 142 | + |
| 143 | + - name: Create multi-arch manifest |
| 144 | + run: | |
| 145 | + image="${{ needs.build.outputs.image }}" |
| 146 | + version="${{ needs.build.outputs.version }}" |
| 147 | +
|
| 148 | + # Create versioned manifest |
| 149 | + podman manifest create "$image:$version" \ |
| 150 | + "$image:$version-amd64" \ |
| 151 | + "$image:$version-arm64" |
| 152 | + podman manifest push "$image:$version" "docker://$image:$version" |
| 153 | +
|
| 154 | + # Create latest manifest |
| 155 | + podman manifest create "$image:latest" \ |
| 156 | + "$image:$version-amd64" \ |
| 157 | + "$image:$version-arm64" |
| 158 | + podman manifest push "$image:latest" "docker://$image:latest" |
0 commit comments