Add containerization (AI-driven) #16
Workflow file for this run
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 | ||
|
Check failure on line 1 in .github/workflows/ci.yml
|
||
| on: | ||
| push: | ||
| branches: [main, master] | ||
| pull_request: | ||
| branches: [main, master] | ||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Set up Go | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: '1.21' | ||
| - name: Verify dependencies | ||
| run: go mod verify | ||
| - name: Build | ||
| run: go build -v ./... | ||
| - name: Run go vet | ||
| run: go vet ./... | ||
| - name: Check formatting | ||
| run: | | ||
| if [ -n "$(gofmt -l .)" ]; then | ||
| echo "Code is not formatted. Run 'gofmt -w .'" | ||
| gofmt -d . | ||
| exit 1 | ||
| fi | ||
| - name: Run tests | ||
| run: go test -v -race -coverprofile=coverage.out ./... | ||
| - name: Upload coverage | ||
| uses: codecov/codecov-action@v4 | ||
| with: | ||
| files: coverage.out | ||
| fail_ci_if_error: false | ||
| validate-rules: | ||
| runs-on: ubuntu-latest | ||
| needs: build | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Set up Go | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: '1.21' | ||
| - name: Build | ||
| run: go build -o bin/metrics-analyzer ./cmd/metrics-analyzer | ||
| - name: Validate rules | ||
| run: ./bin/metrics-analyzer validate ./automated-rules | ||
| container-image: | ||
| runs-on: ubuntu-latest | ||
| needs: build | ||
| if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Read version | ||
| id: version | ||
| run: echo "version=$(cat VERSION)" >> "$GITHUB_OUTPUT" | ||
| - name: Set build time | ||
| id: build_time | ||
| run: echo "build_time=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$GITHUB_OUTPUT" | ||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
| - name: Log in to Quay | ||
| id: login | ||
| if: ${{ secrets.QUAY_USERNAME != '' && secrets.QUAY_PASSWORD != '' }} | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| registry: quay.io | ||
| username: ${{ secrets.QUAY_USERNAME }} | ||
| password: ${{ secrets.QUAY_PASSWORD }} | ||
| - name: Build and push image | ||
| uses: docker/build-push-action@v5 | ||
| with: | ||
| context: . | ||
| file: ./Dockerfile | ||
| push: ${{ steps.login.conclusion == 'success' }} | ||
| tags: | | ||
| quay.io/prygiels/sma:${{ steps.version.outputs.version }} | ||
| quay.io/prygiels/sma:${{ github.sha }} | ||
| quay.io/prygiels/sma:latest | ||
| build-args: | | ||
| VERSION=${{ steps.version.outputs.version }} | ||
| BUILD_TIME=${{ steps.build_time.outputs.build_time }} | ||