CI #30
This file contains hidden or 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: CI | |
| on: | |
| push: | |
| branches: ["main"] | |
| pull_request: | |
| branches: ["main"] | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: ci-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| go: | |
| name: Go | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Set up Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version-file: go.mod | |
| cache: true | |
| - name: Download Go dependencies | |
| run: go mod download | |
| - name: Check Go formatting | |
| run: | | |
| unformatted="$(gofmt -l ./cmd ./internal ./web)" | |
| if [ -n "$unformatted" ]; then | |
| echo "Go files are not formatted:" | |
| echo "$unformatted" | |
| exit 1 | |
| fi | |
| - name: Vet | |
| run: go vet ./cmd/... ./internal/... ./web | |
| - name: Test | |
| run: go test ./... | |
| - name: Build | |
| run: CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /tmp/ephemeral ./cmd/ephemeral | |
| web: | |
| name: Web | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: web | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22 | |
| cache: npm | |
| cache-dependency-path: web/package-lock.json | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Check formatting | |
| run: npx prettier --check "**/*.{html,css,js,json,md,yml,yaml}" | |
| - name: Lint JavaScript | |
| run: npm run lint | |
| docker: | |
| name: Docker build | |
| runs-on: ubuntu-latest | |
| needs: [go, web] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Build Docker image | |
| run: docker build -t ephemeral:ci . | |
| - name: Verify required static files exist in image | |
| run: | | |
| docker run --rm --entrypoint sh ephemeral:ci -c ' | |
| test -f /app/ephemeral | |
| ' |