migrating ci to github actions (#554)

This commit is contained in:
Alex Snast
2020-06-17 18:28:06 +03:00
committed by GitHub
parent c5503d76ad
commit afd1ff0dfd
2 changed files with 312 additions and 0 deletions

36
.github/workflows/cd.yml vendored Normal file
View File

@@ -0,0 +1,36 @@
name: Continuous Deployment
on:
push:
branches:
- master
paths:
- 'doc/**'
jobs:
docs:
name: docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 14
- name: Install Dependencies
working-directory: doc/website
run: yarn
- name: Build Docs
working-directory: doc/website
run: yarn build
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-central-1
- name: Deploy Docs
working-directory: doc/website/build/ent
run: aws s3 sync . s3://entgo.io --delete --exclude "assets/*"
- name: Invalidate Cache
env:
CDN_DISTRIBUTION_ID: ${{ secrets.CDN_DISTRIBUTION_ID }}
run: aws cloudfront create-invalidation --distribution-id $CDN_DISTRIBUTION_ID --paths "/*" | jq -M "del(.Location)"

276
.github/workflows/ci.yml vendored Normal file
View File

@@ -0,0 +1,276 @@
name: Continuous Integration
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run linters
uses: golangci/golangci-lint-action@v1
with:
version: v1.27
unit:
runs-on: ubuntu-latest
strategy:
matrix:
go: ['1.14', '1.13']
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run dialect tests
run: go test -race ./...
working-directory: dialect
- name: Run schema tests
run: go test -race ./...
working-directory: schema
- name: Run loader tests
run: go test -race ./...
working-directory: entc/load
- name: Run codegen tests
run: go test -race ./...
working-directory: entc/gen
- name: Run example tests
working-directory: examples
run: go test -race ./...
generate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run go generate
run: go generate ./...
- name: Check generated files
run: |
status=$(git status --porcelain)
if [ -n "$status" ]; then
echo "you need to run 'go generate ./...' and commit the changes"
echo "$status"
exit 1
fi
integration:
runs-on: ubuntu-latest
services:
mysql56:
image: mysql:5.6.35
env:
MYSQL_DATABASE: test
MYSQL_ROOT_PASSWORD: pass
ports:
- 3306:3306
options: >-
--health-cmd "mysqladmin ping -ppass"
--health-interval 10s
--health-start-period 10s
--health-timeout 5s
--health-retries 10
mysql57:
image: mysql:5.7.26
env:
MYSQL_DATABASE: test
MYSQL_ROOT_PASSWORD: pass
ports:
- 3307:3306
options: >-
--health-cmd "mysqladmin ping -ppass"
--health-interval 10s
--health-start-period 10s
--health-timeout 5s
--health-retries 10
mysql8:
image: mysql:8
env:
MYSQL_DATABASE: test
MYSQL_ROOT_PASSWORD: pass
ports:
- 3308:3306
options: >-
--health-cmd "mysqladmin ping -ppass"
--health-interval 10s
--health-start-period 10s
--health-timeout 5s
--health-retries 10
postgres10:
image: postgres:10
env:
POSTGRES_DB: test
POSTGRES_PASSWORD: pass
ports:
- 5430:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
postgres11:
image: postgres:11
env:
POSTGRES_DB: test
POSTGRES_PASSWORD: pass
ports:
- 5431:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
postgres12:
image: postgres:12.3
env:
POSTGRES_DB: test
POSTGRES_PASSWORD: pass
ports:
- 5433:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
gremlin-server:
image: entgo/gremlin-server
ports:
- 8182:8182
options: >-
--health-cmd "netstat -an | grep -q 8182"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run integration tests
working-directory: entc/integration
run: go test -race -count=2 ./...
migration:
runs-on: ubuntu-latest
if: ${{ github.ref != 'refs/heads/master' }}
services:
mysql56:
image: mysql:5.6.35
env:
MYSQL_DATABASE: test
MYSQL_ROOT_PASSWORD: pass
ports:
- 3306:3306
options: >-
--health-cmd "mysqladmin ping -ppass"
--health-interval 10s
--health-start-period 10s
--health-timeout 5s
--health-retries 10
mysql57:
image: mysql:5.7.26
env:
MYSQL_DATABASE: test
MYSQL_ROOT_PASSWORD: pass
ports:
- 3307:3306
options: >-
--health-cmd "mysqladmin ping -ppass"
--health-interval 10s
--health-start-period 10s
--health-timeout 5s
--health-retries 10
mysql8:
image: mysql:8
env:
MYSQL_DATABASE: test
MYSQL_ROOT_PASSWORD: pass
ports:
- 3308:3306
options: >-
--health-cmd "mysqladmin ping -ppass"
--health-interval 10s
--health-start-period 10s
--health-timeout 5s
--health-retries 10
postgres10:
image: postgres:10
env:
POSTGRES_DB: test
POSTGRES_PASSWORD: pass
ports:
- 5430:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
postgres11:
image: postgres:11
env:
POSTGRES_DB: test
POSTGRES_PASSWORD: pass
ports:
- 5431:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
postgres12:
image: postgres:12.3
env:
POSTGRES_DB: test
POSTGRES_PASSWORD: pass
ports:
- 5433:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
gremlin-server:
image: entgo/gremlin-server
ports:
- 8182:8182
options: >-
--health-cmd "netstat -an | grep -q 8182"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-go@v2
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Checkout origin/master
run: git checkout origin/master
- name: Run integration on origin/master
working-directory: entc/integration
run: go test -race -count=2 ./...
- name: Checkout previous HEAD
run: git checkout -
- name: Run integration on HEAD
working-directory: entc/integration
run: go test -race -count=2 ./...