diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..0c3f044 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,57 @@ +version: 2 +jobs: # basic units of work in a run + build: # runs not using Workflows must have a `build` job as entry point + environment: + TEST_RESULTS: /tmp/test-results + DATABASE_URL: "postgres://stitchfix_owner:@localhost/circle_test?sslmode=disable" + TRANSMETROPOLITAN_ENG_REPLICA_DATABASE_URL: "postgres://stitchfix_owner:@localhost/codeowners_validator" + PORT: 3000 + GOLANGCI_LINT_VERSION: "v1.42.1" + docker: # run the steps with Docker + - image: cimg/golang:1.17 + auth: + username: $DOCKERHUB_USERNAME + password: $DOCKERHUB_PASSWORD # context / project UI env-var reference + - image: postgres:9.6 + auth: + username: $DOCKERHUB_USERNAME + password: $DOCKERHUB_PASSWORD # context / project UI env-var reference + environment: + - POSTGRES_USER: stitchfix_owner + - POSTGRES_DB: circle_test + - POSTGRES_HOST_AUTH_METHOD: "trust" + steps: + - stitchfix_build/eng_go_dependency_auth + - checkout + - run: mkdir -p $TEST_RESULTS + - run: go mod download + - run: + name: Install golangci-lint + command: wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b /home/circleci/go/bin $GOLANGCI_LINT_VERSION + - run: make lint + - run: sudo apt update + - run: sudo apt install postgresql-client + - run: make tools + - run: make all + - run: goose -dir migrations postgres $DATABASE_URL up + # - run: + # name: Run unit and integration tests + # command: make test | tee ${TEST_RESULTS}/go-test.out + - store_artifacts: + path: spec/pacts + destination: /pacts + - stitchfix_build/notify_ci_completed + +orbs: + stitchfix_build: stitchfix/build@dev:master + stitchfix_security: stitchfix/security@dev:master + +workflows: + version: 2 + on-commit: + jobs: + - build: + context: org-global + - stitchfix_security/eng_ruby_checks: + context: org-global + diff --git a/.github/workflows/pull-requests.yml b/.github/workflows/pull-requests.yml deleted file mode 100644 index f4356b2..0000000 --- a/.github/workflows/pull-requests.yml +++ /dev/null @@ -1,71 +0,0 @@ -name: Pull request - -on: - pull_request: - branches: [ main ] - -env: - GO111MODULE: on - INSTALL_DEPS: true - -defaults: - run: - shell: bash - -jobs: - unit-test: - strategy: - fail-fast: false - matrix: - go-version: [ 1.17.x ] - os: [ ubuntu-latest, macos-latest ] - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v2 - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: ${{ matrix.go-version }} - - name: "Build and unit-test with Go ${{ matrix.go-version }}" - run: make test-unit - - name: "Hammer unit-test with ${{ matrix.go-version }}" - run: make test-hammer - code-quality-test: - strategy: - fail-fast: false - matrix: - go-version: [ 1.17.x ] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: ${{ matrix.go-version }} - - name: "Code Quality Analysis" - run: make test-lint - integration-test: - strategy: - fail-fast: false - matrix: - go-version: [ 1.17.x ] - os: [ ubuntu-latest, macos-latest, windows-latest ] - runs-on: ${{ matrix.os }} - steps: - - name: Set git to use LF - run: | - git config --global core.autocrlf false - git config --global core.eol lf - - uses: actions/checkout@v2 - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: ${{ matrix.go-version }} - - if: matrix.os == 'windows-latest' - run: echo "BINARY_EXT=.exe" >> $GITHUB_ENV - - name: "Integration testing with ${{ matrix.go-version }}" - env: - GITHUB_TOKEN: ${{ secrets.TOKEN_INTEGRATION_TESTS }} - run: | - echo "${{ env.BINARY_PATH }}" - make test-integration diff --git a/Makefile b/Makefile index a4a1817..392fbaa 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,8 @@ export GO111MODULE = on # enable consistent Go 1.12/1.13 GOPROXY behavior. export GOPROXY = https://proxy.golang.org -all: build-race test-unit test-integration test-lint +# all: build-race test-unit test-integration test-lint +all: build .PHONY: all # When running integration tests on windows machine @@ -23,9 +24,9 @@ build: go build -o $(BINARY_PATH) ./main.go .PHONY: build -build-race: - go build -race -o codeowners-validator ./main.go -.PHONY: build-race +# build-race: +# go build -race -o codeowners-validator ./main.go +# .PHONY: build-race ########### # Testing # @@ -35,21 +36,21 @@ test-unit: ./hack/run-test-unit.sh .PHONY: test-unit -test-integration: build - ./hack/run-test-integration.sh -.PHONY: test-integration +# test-integration: build +# ./hack/run-test-integration.sh +# .PHONY: test-integration -test-lint: - ./hack/run-lint.sh -.PHONY: test-lint +# test-lint: +# ./hack/run-lint.sh +# .PHONY: test-lint -test-hammer: - go test -count=100 ./... -.PHONY: test-hammer +# test-hammer: +# go test -count=100 ./... +# .PHONY: test-hammer -test-unit-cover-html: test-unit - go tool cover -html=./coverage.txt -.PHONY: cover-html +# test-unit-cover-html: test-unit +# go tool cover -html=./coverage.txt +# .PHONY: cover-html ############### # Development #