Test the storage layer and stop discarding list errors #4
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: [master] | |
| pull_request: | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| name: Build and test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| cache: true | |
| - name: Check formatting | |
| run: | | |
| unformatted=$(gofmt -l .) | |
| if [ -n "$unformatted" ]; then | |
| echo "These files are not gofmt-formatted:" | |
| echo "$unformatted" | |
| exit 1 | |
| fi | |
| - name: Vet | |
| run: go vet ./... | |
| - name: Build | |
| run: go build ./... | |
| - name: Test | |
| run: go test -short ./... | |
| docker: | |
| name: Docker image | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Build image | |
| run: docker build -t timelock-capsule:ci . | |
| # Starting the container proves more than the build does: it catches a | |
| # missing web/ directory, absent CA certificates, and binding to localhost | |
| # instead of all interfaces -- none of which fail at build time. | |
| - name: Start container | |
| run: docker run -d --name tlc -p 8080:8080 timelock-capsule:ci | |
| - name: Wait for health | |
| run: | | |
| for i in $(seq 1 30); do | |
| if curl -sf http://localhost:8080/api/health > /dev/null; then | |
| echo "healthy after ${i}s" | |
| exit 0 | |
| fi | |
| sleep 1 | |
| done | |
| echo "container did not become healthy" | |
| docker logs tlc | |
| exit 1 | |
| - name: Check the UI and its assets are served | |
| run: | | |
| curl -sf http://localhost:8080/ > /dev/null | |
| curl -sf http://localhost:8080/static/css/style.css > /dev/null | |
| curl -sf http://localhost:8080/static/js/app.js > /dev/null | |
| - name: Stop container | |
| if: always() | |
| run: docker rm -f tlc |