chore: gRPC lab TODO #350
This file contains 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: main workflow | |
on: push | |
jobs: | |
lint: | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
- name: setup go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.21' | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v4 | |
with: | |
version: v1.55.2 | |
# test should be run inside a container to start helper services (ex: mongo) | |
test: | |
runs-on: ubuntu-22.04 | |
container: golang:1.21 | |
services: | |
mongo: | |
image: mongo:5 | |
postgres: | |
image: postgres:14-alpine | |
env: | |
POSTGRES_HOST_AUTH_METHOD: trust | |
redis: | |
image: redis:6.2-alpine | |
env: | |
MONGO_URL: mongodb://mongo:27017/ | |
MONGO_DATABASE: nthu_distributes_system | |
POSTGRES_URL: postgres://postgres@postgres:5432/postgres?sslmode=disable | |
REDIS_ADDR: redis:6379 | |
# KAFKA_ADDR: | |
MINIO_ENDPOINT: play.min.io | |
MINIO_BUCKET: videos | |
MINIO_USERNAME: Q3AM3UQ867SPQQA43P2F | |
MINIO_PASSWORD: zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
- name: cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/go/pkg/mod | |
~/.cache/go-build | |
key: ${{ runner.os }}-gocache-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-gocache- | |
- name: test | |
run: go test -v -race ./... | |
# build should be run outside container to build docker image | |
build: | |
runs-on: ubuntu-20.04 | |
needs: | |
- lint | |
- test | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
- name: setup go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: 1.17 | |
- name: cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/go/pkg/mod | |
~/.cache/go-build | |
key: ${{ runner.os }}-gocache-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-gocache- | |
- name: build | |
run: make build | |
- name: login ghcr | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: setup docker buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: set image name | |
run: | | |
echo "IMAGE_NAME=ghcr.io/$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> ${{ github.env }} | |
- name: docker build and push | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
push: true | |
tags: ${{ env.IMAGE_NAME }}:latest,${{ env.IMAGE_NAME }}:${{ github.sha }} |