アクセスのない Runtime App を自動で落とせるようにする #2238
Workflow file for this run
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: CI | |
on: | |
push: | |
branches: | |
- 'main' | |
pull_request: | |
jobs: | |
mod: | |
name: Modules | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version-file: ./go.mod | |
- run: go mod download | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
needs: [mod] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version-file: ./go.mod | |
- run: go build -o ns ./cmd | |
lint: | |
name: Lint | |
runs-on: ubuntu-latest | |
needs: [mod] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version-file: ./go.mod | |
- name: Install reviewdog | |
run: curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b $(go env GOPATH)/bin | |
- name: Install golangci-lint | |
run: curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin | |
- name: Run golangci-lint | |
run: golangci-lint run --out-format=line-number | reviewdog -f=golangci-lint -name=golangci-lint -reporter=github-check | |
env: | |
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
needs: [mod] | |
strategy: | |
matrix: | |
race: | |
- "" | |
- -race | |
env: | |
ENABLE_DB_TESTS: "true" | |
ENABLE_DOCKER_TESTS: "true" | |
DOCKER_API_VERSION: "1.43" | |
services: | |
mysql: | |
image: mysql:8 | |
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=3s --health-retries=10 | |
env: | |
MYSQL_ROOT_PASSWORD: password | |
MYSQL_DATABASE: neoshowcase | |
ports: | |
- 5004:3306 | |
mongo: | |
image: mongo | |
env: | |
MONGO_INITDB_ROOT_USERNAME: root | |
MONGO_INITDB_ROOT_PASSWORD: password | |
ports: | |
- 5010:27017 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version-file: ./go.mod | |
- name: Run migration | |
run: | | |
go install github.com/sqldef/sqldef/cmd/mysqldef@latest | |
DB_PORT=5004 ./migrations/entrypoint.sh ./migrations/schema.sql | |
- name: Run tests | |
run: go test ./... -v ${{ matrix.race }} -coverprofile=coverage.out -covermode=atomic -vet=off | |
- name: Upload coverage to Codecov | |
run: bash <(curl -s https://codecov.io/bash) | |
if: matrix.race == '' | |
k8s-test: | |
name: K8s Test | |
runs-on: ubuntu-latest | |
needs: [mod] | |
strategy: | |
matrix: | |
race: | |
- "" | |
- -race | |
env: | |
ENABLE_K8S_TESTS: "true" | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version-file: ./go.mod | |
- name: Create single cluster | |
uses: AbsaOSS/k3d-action@v2 | |
id: single-cluster | |
with: | |
cluster-name: "test-cluster" | |
args: >- | |
--agents 1 | |
--no-lb | |
--k3s-arg "--disable=traefik,servicelb,metrics-server@server:0" | |
- name: Show cluster info | |
run: | | |
echo ${{ steps.single-cluster.outputs.network }} | |
echo ${{ steps.single-cluster.outputs.subnet-CIDR }} | |
docker ps -a | |
kubectl cluster-info --context k3d-test-cluster | |
kubectl config use-context k3d-test-cluster | |
kubectl get nodes -o wide | |
- name: Create namespace | |
run: kubectl create ns neoshowcase-apps | |
- name: Install CRDs | |
run: | | |
kubectl apply -f https://raw.githubusercontent.com/traefik/traefik/v3.0.0/docs/content/reference/dynamic-configuration/kubernetes-crd-definition-v1.yml | |
- name: Run tests | |
run: go test ./pkg/infrastructure/backend/k8simpl -v ${{ matrix.race }} -coverprofile=coverage.out -covermode=atomic -vet=off | |
- name: Upload coverage to Codecov | |
run: bash <(curl -s https://codecov.io/bash) | |
if: matrix.race == '' | |
tbls: | |
name: TBLS | |
runs-on: ubuntu-latest | |
services: | |
mysql: | |
image: mariadb:10.8.3 | |
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3 | |
env: | |
MYSQL_ROOT_PASSWORD: password | |
MYSQL_DATABASE: neoshowcase | |
ports: | |
- 5004:3306 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version-file: ./go.mod | |
- name: Run migration | |
run: | | |
go install github.com/sqldef/sqldef/cmd/mysqldef@latest | |
DB_PORT=5004 ./migrations/entrypoint.sh ./migrations/schema.sql | |
- uses: k1low/setup-tbls@v1 | |
with: | |
version: v1.65.3 | |
- run: tbls lint | |
env: | |
TBLS_DSN: "mariadb://root:[email protected]:5004/neoshowcase" |