From 15612b8b925bc88b3a9019e89a17e21d4695c2b6 Mon Sep 17 00:00:00 2001 From: "garrison.davis@molecula.com" Date: Tue, 21 Dec 2021 13:58:10 -0700 Subject: [PATCH] Run integration on merge to default branch Additionally, the go version is using the GOVERSION build variable instead. --- .gitlab/.gitlab-ci.yml | 52 +++++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/.gitlab/.gitlab-ci.yml b/.gitlab/.gitlab-ci.yml index 0b7cc21e9..a27c1012e 100644 --- a/.gitlab/.gitlab-ci.yml +++ b/.gitlab/.gitlab-ci.yml @@ -11,7 +11,7 @@ include: paths: - .go/pkg/mod/ variables: - GOVERSION: "1.16.9" + GOVERSION: "1.16.10" stages: - lint @@ -19,19 +19,13 @@ stages: - build - integration - #before_script: - #- echo "before_script" - #- git version - #- go env -w GOPRIVATE=github.com/molecula - #- mkdir -p .go - #- go version - #- go env -w GO111MODULE=on - golangci-lint: image: golangci/golangci-lint:v1.39.0 stage: lint extends: .go-cache allow_failure: false + rules: + - if: '$CI_PIPELINE_SOURCE == "push"' script: - echo "Checking for issues in new code" - golangci-lint run -v @@ -41,6 +35,8 @@ build lattice: image: node:14 variables: CI: "false" + rules: + - if: '$CI_PIPELINE_SOURCE == "push"' script: - cd lattice - yarn install @@ -59,6 +55,8 @@ run jest tests: image: node:14 variables: CI: "true" + rules: + - if: '$CI_PIPELINE_SOURCE == "push"' script: - echo "Testing lattice..." - cd lattice @@ -70,8 +68,10 @@ run jest tests: run go tests: stage: test - image: golang:1.16.10 + image: golang:$GOVERSION extends: .go-cache + rules: + - if: '$CI_PIPELINE_SOURCE == "push"' script: - echo "Running featurebase unit tests..." - PKG_LIST=$(go list ./... | grep -v internal/clustertests | paste -s -d, -) @@ -84,6 +84,8 @@ run go tests future: stage: test image: golang:1.17.3 extends: .go-cache + rules: + - if: '$CI_PIPELINE_SOURCE == "push"' script: - echo "Running featurebase unit tests..." - PKG_LIST=$(go list ./... | grep -v internal/clustertests | paste -s -d, -) @@ -95,7 +97,9 @@ run go tests future: run go tests with output: stage: test - image: golang:1.16.10 + image: golang:$GOVERSION + rules: + - if: '$CI_PIPELINE_SOURCE == "push"' script: - echo "Running featurebase unit tests to capture JSON output..." - go test -json > test-report.out @@ -108,6 +112,8 @@ upload to sonarcloud: image: sonarsource/sonar-scanner-cli:4.6 variables: SONAR_TOKEN: $SONAR_TOKEN + rules: + - if: '$CI_PIPELINE_SOURCE == "push"' script: - sonar-scanner -Dsonar.projectKey=molecula_featurebase -Dsonar.organization=molecula -Dsonar.sources=. -Dsonar.host.url=https://sonarcloud.io -Dsonar.go.coverage.reportPaths=coverage.out -Dsonar.go.tests.reportPaths=test-report.out -Dsonar.javascript.lcov.reportPaths=lattice/coverage/lcov.info needs: @@ -117,7 +123,9 @@ upload to sonarcloud: build for linux amd64: stage: build - image: golang:1.16.10 + image: golang:$GOVERSION + rules: + - if: '$CI_PIPELINE_SOURCE == "push"' script: - rm -r lattice - tar -xvf lattice.tar.gz @@ -130,7 +138,9 @@ build for linux amd64: build for linux arm64: stage: build - image: golang:1.16.10 + image: golang:$GOVERSION + rules: + - if: '$CI_PIPELINE_SOURCE == "push"' script: - rm -r lattice - tar -xvf lattice.tar.gz @@ -143,7 +153,9 @@ build for linux arm64: build for darwin amd64: stage: build - image: golang:1.16.10 + image: golang:$GOVERSION + rules: + - if: '$CI_PIPELINE_SOURCE == "push"' script: - rm -r lattice - tar -xvf lattice.tar.gz @@ -156,7 +168,9 @@ build for darwin amd64: build for darwin arm64: stage: build - image: golang:1.16.10 + image: golang:$GOVERSION + rules: + - if: '$CI_PIPELINE_SOURCE == "push"' script: - rm -r lattice - tar -xvf lattice.tar.gz @@ -169,7 +183,9 @@ build for darwin arm64: package for linux amd64: stage: build - image: golang:1.16.10 + image: golang:$GOVERSION + rules: + - if: '$CI_PIPELINE_SOURCE == "push"' variables: GOOS: "linux" GOARCH: "amd64" @@ -190,6 +206,8 @@ build container fb: - "build for linux amd64" tags: - shell + rules: + - if: '$CI_PIPELINE_SOURCE == "push"' before_script: - echo "${DOCKER_DEPLOY_TOKEN}" | docker login -u ${DOCKER_DEPLOY_USER} --password-stdin ${CI_REGISTRY} script: @@ -205,6 +223,8 @@ deploy node for linux amd64: variables: PROFILE: "default" AWS_SSH_PRIVATE_KEY: $AWS_SSH_PRIVATE_KEY + rules: + - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' before_script: - aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID - aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY