Files
catalyst/.github/workflows/ci.yml
2022-05-07 11:51:16 +02:00

218 lines
6.5 KiB
YAML
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: CI
on:
push: { branches: [ main ] }
pull_request:
release: { types: [ published ] }
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with: { go-version: '1.18' }
- id: goenv
run: |
echo "::set-output name=gocache::$(go env GOCACHE)"
echo "::set-output name=gomodcache::$(go env GOMODCACHE)"
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: ${{ steps.goenv.outputs.gocache }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
- uses: actions/cache@v3
with:
path: ${{ steps.goenv.outputs.gomodcache }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
- run: |
mkdir -p ui/dist/img
touch ui/dist/index.html ui/dist/favicon.ico ui/dist/manifest.json ui/dist/img/fake.png
- uses: golangci/golangci-lint-action@v3
test:
name: Test
runs-on: ubuntu-latest
env: { GIN_MODE: test }
steps:
- uses: actions/setup-go@v3
with: { go-version: '1.18' }
- uses: actions/setup-node@v3
with: { node-version: '14' }
- id: goenv
run: |
echo "::set-output name=gocache::$(go env GOCACHE)"
echo "::set-output name=gomodcache::$(go env GOMODCACHE)"
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: ${{ steps.goenv.outputs.gocache }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
- uses: actions/cache@v3
with:
path: ${{ steps.goenv.outputs.gomodcache }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
- run: |
mkdir -p ui/dist/img
touch ui/dist/index.html ui/dist/favicon.ico ui/dist/manifest.json ui/dist/img/fake.png
- run: docker-compose up -d
working-directory: dev
- name: Install ArangoDB
run: |
curl -OL https://download.arangodb.com/arangodb38/DEBIAN/Release.key
sudo apt-key add Release.key
sudo apt-add-repository 'deb https://download.arangodb.com/arangodb38/DEBIAN/ /'
sudo apt-get update -y && sudo apt-get -y install arangodb3
- run: go test -coverprofile=cover.out -coverpkg=./... ./...
- run: go tool cover -func=cover.out
- uses: codecov/codecov-action@v3
gocap:
name: gocap
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with: { go-version: '1.18' }
- uses: actions/checkout@v3
- run: go mod download
- run: go install github.com/cugu/gocap@main
- run: |
mkdir -p ui/dist/img
touch ui/dist/index.html ui/dist/favicon.ico ui/dist/manifest.json ui/dist/img/fake.png
- run: go list --json ./cmd/catalyst
- run: gocap check ./cmd/catalyst
cypress:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/setup-go@v3
with: { go-version: '1.18' }
- uses: actions/setup-node@v3
with: { node-version: '14' }
# run UI
- run: |
yarn install
yarn serve &
working-directory: ui
- uses: cugu/wait_for_response@v1.8.0
with:
url: 'http://localhost:8080'
responseCode: 200
# run containers
- run: sed -i 's/host.docker.internal/172.17.0.1/g' dev/nginx.conf
shell: bash
- run: docker-compose up --quiet-pull --detach
working-directory: dev
shell: bash
- uses: cugu/wait_for_response@v1.8.0
with:
url: 'http://localhost:9002/auth/realms/catalyst'
responseCode: 200
# run catalyst
- run: |
mkdir -p ui/dist/img
touch ui/dist/index.html ui/dist/favicon.ico ui/dist/manifest.json ui/dist/img/fake.png
- run: go mod download
- run: bash start_dev.sh &
- uses: cugu/wait_for_response@v1.8.0
with:
url: 'http://localhost:8000'
responseCode: 302
verbose: true
timeout: 3m # 3 minutes
interval: 10s # every 10 seconds
# run cypress
- run: ./node_modules/.bin/cypress run
working-directory: ui
- uses: actions/upload-artifact@v3
with:
name: cypress-videos
path: ui/cypress/videos
retention-days: 1
build-npm:
name: Build npm
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v3
with: { node-version: '14' }
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- run: yarn install && yarn build
working-directory: ui
- uses: actions/upload-artifact@v3
with: { name: ui, path: ui/dist, retention-days: 1 }
build:
if: github.event_name != 'pull_request'
name: Build
runs-on: ubuntu-latest
needs: [ build-npm, test ]
steps:
- uses: actions/setup-go@v3
with: { go-version: '1.18' }
- id: goenv
run: |
echo "::set-output name=gocache::$(go env GOCACHE)"
echo "::set-output name=gomodcache::$(go env GOMODCACHE)"
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: ${{ steps.goenv.outputs.gocache }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
- uses: actions/cache@v3
with:
path: ${{ steps.goenv.outputs.gomodcache }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
- uses: actions/download-artifact@v3
with: { name: ui, path: ui/dist }
- run: go build -o catalyst ./cmd/catalyst/.
- uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Version
if: ${{ github.ref != '' }}
run: |
echo ${{ github.ref_name }}
echo ${{ github.ref_name }} > VERSION
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}