Skip to content

update

update #1466

Workflow file for this run

name: Test and build
on:
pull_request:
types:
- opened
push:
jobs:
tests:
name: Test
strategy:
matrix:
go_version:
- "1.22"
- "1.23"
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
with:
show-progress: false
- name: Use golang ${{ matrix.go_version }}
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version: ${{ matrix.go_version }}
check-latest: true
- name: Go get dependencies
run: go get -v -t -d ./...
- name: Run tests
run: make coverage
- name: Send the coverage output
uses: coverallsapp/github-action@4cdef0b2dbe0c9aa26bed48edb868db738625e79 # v2.3.3
with:
flag-name: go-${{ join(matrix.*, '-') }}
parallel: true
file: coverage.out
post-tests:
needs: tests
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@4cdef0b2dbe0c9aa26bed48edb868db738625e79 # v2.3.3
with:
parallel-finished: true
test-latest:
name: Test latest
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Checkout repository
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
with:
show-progress: false
- name: Use golang stable
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version: stable
check-latest: true
- name: Go get dependencies
run: go get -v -t -d ./...
- name: Run tests
run: make coverage
bench:
name: Benchmark
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
with:
show-progress: false
- name: Setup golang
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version-file: go.mod
check-latest: true
- name: Run benchmark
run: make bench | tee output.txt; exit ${PIPESTATUS[0]}
- name: Download previous benchmark data
uses: actions/cache/restore@3624ceb22c1c5a301c8db4169662070a689d9ea8 # v4.1.1
with:
path: ./cache
key: ${{ runner.os }}-benchmark
- name: Store benchmark result
uses: benchmark-action/github-action-benchmark@4de1bed97a47495fc4c5404952da0499e31f5c29 # v1.20.3
with:
tool: go
output-file-path: ./output.txt
external-data-json-path: ./cache/benchmark-data.json
comment-on-alert: false
fail-on-alert: true
# only execute this step when cache was restored
# do not fail hard here, as the key might not exist
- name: Clear cache
shell: bash
if: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
env:
GH_TOKEN: ${{ github.token }}
run: |
gh extension install actions/gh-actions-cache
gh actions-cache delete '${{ runner.os }}-benchmark' --confirm
continue-on-error: true
- name: Update benchmark data
if: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
uses: actions/cache/save@3624ceb22c1c5a301c8db4169662070a689d9ea8 # v4.1.1
with:
path: ./cache
key: ${{ runner.os }}-benchmark
build:
name: Build Docker Images
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/tags/') || github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
permissions:
actions: read
contents: write
packages: write
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
with:
show-progress: false
- name: Docker Login to GitHub Repository
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker Login to DockerHub
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
username: ${{ secrets.BOT_DOCKER_USERNAME }}
password: ${{ secrets.BOT_DOCKER_TOKEN }}
- name: Login to Mia registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: nexus.mia-platform.eu
username: ${{ secrets.MIA_PLATFORM_DOCKER_REGISTRY_USERNAME }}
password: ${{ secrets.MIA_PLATFORM_DOCKER_REGISTRY_PASSWORD }}
- name: Install Cosign
uses: sigstore/cosign-installer@dc72c7d5c4d10cd6bcb8cf6e3fd625a9e5e537da # v3.7.0
- name: Set up QEMU
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0
with:
platforms: amd64,arm64
- name: Configure docker metadata
id: meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
env:
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
with:
images: |
ghcr.io/rond-authz/rond
docker.io/rondauthz/rond
nexus.mia-platform.eu/rond-authz/rond
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
labels: |
org.opencontainers.image.documentation=https://rond-authz.io
org.opencontainers.image.vendor=rond authz
annotations: |
org.opencontainers.image.documentation=https://rond-authz.io
org.opencontainers.image.vendor=rond authz
- name: Setup Buildx Context
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1
id: buildx
with:
platforms: linux/amd64,linux/arm64
- name: Build and push
id: docker-build
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6.9.0
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.output.annotations }}
platforms: ${{ steps.buildx.outputs.platforms }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Generate SBOM
uses: anchore/sbom-action@8d0a6505bf28ced3e85154d13dc6af83299e13f1 # v0.17.4
if: github.ref_type == 'tag'
with:
artifact-name: rond-authz-sbom.spdx.json
output-file: ./rond-authz-sbom.spdx.json
image: nexus.mia-platform.eu/rond-authz/rond:${{ steps.meta.output.version.main }}
upload-release-assets: true
- name: GCP Auth
uses: google-github-actions/auth@8254fb75a33b976a221574d287e93919e6a36f70 # v2.1.6
if: github.ref_type == 'tag'
with:
project_id: ${{ secrets.MIA_PLATFORM_KMS_PROJECT }}
workload_identity_provider: ${{ secrets.MIA_PLATFORM_GCP_WIF }}
create_credentials_file: true
- name: Sign public images with Mia-Platform key
if: github.ref_type == 'tag'
run: |
for tag in ${TAGS}; do
image="${tag}@${DIGEST}"
cosign sign --recursive --yes --key "${COSIGN_PRIVATE_KEY}" "${image}"
cosign attest --recursive --yes --key "${COSIGN_PRIVATE_KEY}" --predicate "rond-authz-sbom.spdx.json" --type="spdxjson" "${image}"
done
env:
TAGS: |
ghcr.io/rond-authz/rond:${{ steps.meta.output.version.main }}
docker.io/rondauthz/rond:${{ steps.meta.output.version.main }}
nexus.mia-platform.eu/rond-authz/rond:${{ steps.meta.output.version.main }}
DIGEST: ${{ steps.docker-build.outputs.digest }}
COSIGN_PRIVATE_KEY: ${{ secrets.MIA_PLATFORM_COSIGN_KEY }}