|
| 1 | +name: ci |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | +env: |
| 9 | + # Default minimum version of Go to support. |
| 10 | + DEFAULT_GO_VERSION: 1.18 |
| 11 | +jobs: |
| 12 | + lint: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - name: Install Go |
| 16 | + uses: actions/setup-go@v3 |
| 17 | + with: |
| 18 | + go-version: ${{ env.DEFAULT_GO_VERSION }} |
| 19 | + - name: Checkout repository |
| 20 | + uses: actions/checkout@v3 |
| 21 | + - name: Setup Environment |
| 22 | + run: | |
| 23 | + echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV |
| 24 | + echo "$(go env GOPATH)/bin" >> $GITHUB_PATH |
| 25 | + - name: Module cache |
| 26 | + uses: actions/cache@v3 |
| 27 | + env: |
| 28 | + cache-name: go-mod-cache |
| 29 | + with: |
| 30 | + path: ~/go/pkg/mod |
| 31 | + key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/go.sum') }} |
| 32 | + - name: Run linter |
| 33 | + run: make lint |
| 34 | + |
| 35 | + test: |
| 36 | + runs-on: ubuntu-latest |
| 37 | + steps: |
| 38 | + - name: Install Go |
| 39 | + uses: actions/setup-go@v3 |
| 40 | + with: |
| 41 | + go-version: ${{ env.DEFAULT_GO_VERSION }} |
| 42 | + - name: Checkout repository |
| 43 | + uses: actions/checkout@v3 |
| 44 | + - name: Setup Environment |
| 45 | + run: | |
| 46 | + echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV |
| 47 | + echo "$(go env GOPATH)/bin" >> $GITHUB_PATH |
| 48 | + - name: Module cache |
| 49 | + uses: actions/cache@v3 |
| 50 | + env: |
| 51 | + cache-name: go-mod-cache |
| 52 | + with: |
| 53 | + path: ~/go/pkg/mod |
| 54 | + key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/go.sum') }} |
| 55 | + - name: Run tests |
| 56 | + run: make test |
| 57 | + - name: Upload coverage to Codecov |
| 58 | + uses: codecov/codecov-action@v3 |
| 59 | + |
| 60 | + docker-local: |
| 61 | + runs-on: ubuntu-latest |
| 62 | + steps: |
| 63 | + - name: Checkout |
| 64 | + uses: actions/checkout@v3 |
| 65 | + with: |
| 66 | + submodules: recursive |
| 67 | + - name: Set up QEMU |
| 68 | + uses: docker/setup-qemu-action@master |
| 69 | + with: |
| 70 | + platforms: all |
| 71 | + - name: Set up Docker Buildx |
| 72 | + id: buildx |
| 73 | + uses: docker/setup-buildx-action@master |
| 74 | + - name: Build |
| 75 | + uses: docker/build-push-action@v2 |
| 76 | + with: |
| 77 | + context: . |
| 78 | + outputs: type=docker,dest=${{ github.workspace }}/open-feature-operator-local.tar |
| 79 | + tags: open-feature-operator-local:test |
| 80 | + - name: Run Trivy vulnerability scanner |
| 81 | + uses: aquasecurity/trivy-action@master |
| 82 | + with: |
| 83 | + input: /github/workspace/open-feature-operator-local.tar |
| 84 | + format: "template" |
| 85 | + template: "@/contrib/sarif.tpl" |
| 86 | + output: "trivy-results.sarif" |
| 87 | + severity: "CRITICAL,HIGH" |
| 88 | + - name: Upload Trivy scan results to GitHub Security tab |
| 89 | + uses: github/codeql-action/upload-sarif@v2 |
| 90 | + with: |
| 91 | + sarif_file: "trivy-results.sarif" |
0 commit comments