version: 2.1 aliases: - &mktestdir run: name: Create results directory command: mkdir -p ~/test-results - &storetestdir store_test_results: path: ~/test-results orbs: aws-cli: circleci/aws-cli@1.0.0 go: circleci/go@1.1.1 commands: getmods: steps: - go/load-cache - go/mod-download - go/save-cache jobs: lint: docker: - image: golangci/golangci-lint:v1.28-alpine steps: - checkout - *mktestdir - run: name: Run linters command: golangci-lint run --out-format junit-xml > ~/test-results/lint.xml - *storetestdir unit: executor: name: go/default tag: '1.15' steps: - checkout - *mktestdir - getmods - run: name: Dialect tests command: gotestsum -f short-verbose --junitfile ~/test-results/dialect.xml working_directory: dialect - run: name: Schema tests command: gotestsum -f short-verbose --junitfile ~/test-results/schema.xml working_directory: schema - run: name: Loader tests command: gotestsum -f short-verbose --junitfile ~/test-results/load.xml working_directory: entc/load - run: name: Codegen tests command: gotestsum -f short-verbose --junitfile ~/test-results/gen.xml working_directory: entc/gen - *storetestdir integration: docker: &integration-docker - image: circleci/golang - image: circleci/mysql:5.6.35 environment: &mysql_env MYSQL_DATABASE: test MYSQL_ROOT_PASSWORD: pass - image: circleci/mysql:5.7.26 environment: <<: *mysql_env MYSQL_TCP_PORT: 3307 - image: circleci/mysql environment: <<: *mysql_env MYSQL_TCP_PORT: 3308 - image: circleci/postgres:10.0 environment: POSTGRES_DB: test POSTGRES_PASSWORD: pass command: -p 5430 - image: circleci/postgres:11.0 environment: POSTGRES_DB: test POSTGRES_PASSWORD: pass command: -p 5431 - image: circleci/postgres:12.3 environment: POSTGRES_DB: test POSTGRES_PASSWORD: pass command: -p 5433 - image: circleci/postgres:13.1 environment: POSTGRES_DB: test POSTGRES_PASSWORD: pass command: -p 5434 - image: entgo/gremlin-server entrypoint: /opt/gremlin-server/bin/gremlin-server.sh command: conf/gremlin-server.yaml steps: - checkout - run: &integration-wait name: Wait for databases command: >- dockerize -timeout 2m -wait tcp://localhost:3306 -wait tcp://localhost:3307 -wait tcp://localhost:3308 -wait tcp://localhost:5430 -wait tcp://localhost:5431 -wait tcp://localhost:5433 -wait tcp://localhost:8182 - *mktestdir - getmods - run: name: Run codegen for examples working_directory: examples command: go generate ./... - run: name: Run example tests working_directory: examples command: gotestsum -f short-verbose --junitfile ~/test-results/examples.xml -- -race ./... - run: name: Run codegen for entc/load working_directory: entc/load command: go generate - run: name: Run codegen for entc/gen working_directory: entc/gen command: go generate - run: name: Run codegen for entc/integration working_directory: entc/integration command: go generate - run: name: Check untracked files command: | if [[ `git status --porcelain` ]] then echo "Running 'go generate ./...' introduced untracked files" git status --porcelain exit 1 fi - run: name: Run integration tests working_directory: entc/integration command: gotestsum -f short-verbose --junitfile ~/test-results/integration.xml -- -race -count=2 -tags='json1' ./... - *storetestdir migration: docker: *integration-docker steps: - checkout - run: *integration-wait - *mktestdir - getmods - run: name: Checkout master command: git checkout origin/master - run: name: Run integration on master working_directory: entc/integration command: gotestsum -f short-verbose --junitfile ~/test-results/master-integration.xml -- -race -count=2 . - run: name: Checkout PR branch command: git checkout "$CIRCLE_BRANCH" - run: name: Run integration on PR branch working_directory: entc/integration command: gotestsum -f short-verbose --junitfile ~/test-results/pr-integration.xml -- -race -count=2 . - *storetestdir docs: docker: - image: circleci/node steps: - checkout - run: name: Checking Docs Modified command: | if [[ ! $(git diff master^ --name-only doc/) ]]; then echo "docs not modified; no need to deploy" circleci step halt fi - run: name: Install Dependencies working_directory: ~/project/doc/website command: yarn - run: name: Build Docs working_directory: ~/project/doc/website command: yarn build - aws-cli/setup - run: name: Deploy Docs working_directory: ~/project/doc/website/build/ent command: aws s3 sync . s3://entgo.io --delete --exclude "assets/*" - run: name: Invalidate Cache command: aws cloudfront create-invalidation --distribution-id $CDN_DISTRIBUTION_ID --paths "/*" | jq -M "del(.Location)" workflows: version: 2.1 all: jobs: - lint - unit - integration - migration: filters: branches: ignore: master - docs: filters: branches: only: master