Skip to content

go

go #812

Workflow file for this run

name: go
on:
push:
paths:
- "samples/go/**"
- ".github/workflows/go.yml"
- "restarter/**"
schedule:
- cron: '0 7 * * *'
env:
REGISTRY: ghcr.io
IMAGE_NAME: miracl/oidc-samples/samples/go
DOCKER_BUILD_CONTEXT: samples/go
SAMPLE_IMAGE: ghcr.io/miracl/oidc-samples/samples/go:${{ github.sha }}
PROXY_IMAGE: ghcr.io/miracl/oidc-samples/proxy:latest
TESTS_IMAGE: ghcr.io/miracl/oidc-samples/integration-tests:latest
CLIENT_ID: ${{ vars.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
PROJECT_ID: ${{ vars.PROJECT_ID }}
jobs:
lint-go:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: 1.*
- name: Go lint
run: test -z "$(gofmt -s -l . 2>&1 | grep -v vendor | tee /dev/stderr)"
build-docker:
needs: lint-go
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: docker/setup-buildx-action@v1
- uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
latest=${{ github.ref == 'refs/heads/master' }}
tags: |
type=raw,value=${{ github.sha }}
- uses: docker/build-push-action@v2
with:
context: ${{ env.DOCKER_BUILD_CONTEXT }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
run-integration-tests:
needs: build-docker
runs-on: ubuntu-latest
steps:
- name: Pull images
run: |
docker pull --quiet $SAMPLE_IMAGE
docker pull --quiet $TESTS_IMAGE
- name: Start the sample
run: docker run
--detach
--network host
--publish 8000
--name sample
--env CLIENT_ID
--env CLIENT_SECRET
$SAMPLE_IMAGE
- name: Sleep for a seconds
run: sleep 1s
shell: bash
- name: Run integration tests
run: docker run
--network host
$TESTS_IMAGE
--client-id $CLIENT_ID
--client-secret $CLIENT_SECRET
--project-id $PROJECT_ID
run-integration-tests-with-proxy:
needs: build-docker
runs-on: ubuntu-latest
steps:
- name: Pull images
run: |
docker pull --quiet $PROXY_IMAGE
docker pull --quiet $SAMPLE_IMAGE
docker pull --quiet $TESTS_IMAGE
- name: Start the proxy
run: docker run
--detach
--network host
--publish 8080
$PROXY_IMAGE
- name: Checkout repository content
uses: actions/checkout@v2
- name: Run the restarter
run: go run ./restarter/main.go &
- name: Start the sample
run: docker run
--detach
--network host
--publish 8080
--name sample
--env CLIENT_ID
--env CLIENT_SECRET
--env PROXY_HOST=127.0.0.1
--env PROXY_PORT=8080
$SAMPLE_IMAGE
- name: Sleep for a seconds
run: sleep 1s
shell: bash
- name: Run integration tests
run: docker run
--network host
$TESTS_IMAGE
--client-id $CLIENT_ID
--client-secret $CLIENT_SECRET
--project-id $PROJECT_ID
--sample-name sample
--proxy-host 127.0.0.1
--proxy-port 8080
--skip-modify-tests false