Fixed commenting in the gitlab CI file.

This commit is contained in:
Fletcher Haynes 2022-01-03 12:21:32 -08:00
parent fa9ae13363
commit 4016a1d03d

View file

@ -1,7 +1,7 @@
# include:
# - template: Security/SAST.gitlab-ci.yml
# - template: Security/License-Scanning.gitlab-ci.yml
# - template: Security/Dependency-Scanning.gitlab-ci.yml
include:
- template: Security/SAST.gitlab-ci.yml
- template: Security/License-Scanning.gitlab-ci.yml
- template: Security/Dependency-Scanning.gitlab-ci.yml
.go-cache:
variables:
@ -14,31 +14,30 @@ variables:
GOVERSION: "1.16.10"
stages:
# - lint
- lint
- test
- build
# - integration
- integration
- gauntlet
# 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
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
build lattice:
stage: test
image: node:14
variables:
CI: "false"
# TODO: For now, always do this
# rules:
# - if: '$CI_PIPELINE_SOURCE == "push"'
rules:
- if: '$CI_PIPELINE_SOURCE == "push"'
script:
- cd lattice
- yarn install
@ -52,83 +51,82 @@ build lattice:
paths:
- lattice.tar.gz
# run jest tests:
# stage: test
# image: node:14
# variables:
# CI: "true"
# rules:
# - if: '$CI_PIPELINE_SOURCE == "push"'
# script:
# - echo "Testing lattice..."
# - cd lattice
# - npm install --force
# - npm test -- --coverage --testResultsProcessor=jest-sonar-reporter
# artifacts:
# paths:
# - lattice/coverage/lcov.info
run jest tests:
stage: test
image: node:14
variables:
CI: "true"
rules:
- if: '$CI_PIPELINE_SOURCE == "push"'
script:
- echo "Testing lattice..."
- cd lattice
- npm install --force
- npm test -- --coverage --testResultsProcessor=jest-sonar-reporter
artifacts:
paths:
- lattice/coverage/lcov.info
# run go tests:
# stage: test
# 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, -)
# - go test -coverprofile=coverage.out -covermode=atomic -coverpkg=${PKG_LIST} ./...
# artifacts:
# paths:
# - coverage.out
run go tests:
stage: test
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, -)
- go test -coverprofile=coverage.out -covermode=atomic -coverpkg=${PKG_LIST} ./...
artifacts:
paths:
- coverage.out
# 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, -)
# - go test -coverprofile=coverage.out -covermode=atomic -coverpkg=${PKG_LIST} ./...
# artifacts:
# paths:
# - coverage.out
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, -)
- go test -coverprofile=coverage.out -covermode=atomic -coverpkg=${PKG_LIST} ./...
artifacts:
paths:
- coverage.out
# run go tests with output:
# stage: test
# 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
# artifacts:
# paths:
# - test-report.out
run go tests with output:
stage: test
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
artifacts:
paths:
- test-report.out
# upload to sonarcloud:
# stage: test
# 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:
# - job: run go tests
# - job: run go tests with output
# - job: run jest tests
upload to sonarcloud:
stage: test
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:
- job: run go tests
- job: run go tests with output
- job: run jest tests
build for linux amd64:
stage: build
image: golang:$GOVERSION
# TODO: For now, run always
# rules:
# - if: '$CI_PIPELINE_SOURCE == "push"'
rules:
- if: '$CI_PIPELINE_SOURCE == "push"'
script:
- rm -r lattice
- tar -xvf lattice.tar.gz
@ -154,98 +152,98 @@ build for linux arm64:
paths:
- featurebase_linux_arm64
# build for darwin amd64:
# stage: build
# image: golang:$GOVERSION
# rules:
# - if: '$CI_PIPELINE_SOURCE == "push"'
# script:
# - rm -r lattice
# - tar -xvf lattice.tar.gz
# - go get -v -u github.com/rakyll/statik
# - /go/bin/statik -src=lattice
# - GOOS="darwin" GOARCH="amd64" make build FLAGS="-o featurebase_darwin_amd64"
# artifacts:
# paths:
# - featurebase_darwin_amd64
build for darwin amd64:
stage: build
image: golang:$GOVERSION
rules:
- if: '$CI_PIPELINE_SOURCE == "push"'
script:
- rm -r lattice
- tar -xvf lattice.tar.gz
- go get -v -u github.com/rakyll/statik
- /go/bin/statik -src=lattice
- GOOS="darwin" GOARCH="amd64" make build FLAGS="-o featurebase_darwin_amd64"
artifacts:
paths:
- featurebase_darwin_amd64
# build for darwin arm64:
# stage: build
# image: golang:$GOVERSION
# rules:
# - if: '$CI_PIPELINE_SOURCE == "push"'
# script:
# - rm -r lattice
# - tar -xvf lattice.tar.gz
# - go get -v -u github.com/rakyll/statik
# - /go/bin/statik -src=lattice
# - GOOS="darwin" GOARCH="arm64" make build FLAGS="-o featurebase_darwin_arm64"
# artifacts:
# paths:
# - featurebase_darwin_arm64
build for darwin arm64:
stage: build
image: golang:$GOVERSION
rules:
- if: '$CI_PIPELINE_SOURCE == "push"'
script:
- rm -r lattice
- tar -xvf lattice.tar.gz
- go get -v -u github.com/rakyll/statik
- /go/bin/statik -src=lattice
- GOOS="darwin" GOARCH="arm64" make build FLAGS="-o featurebase_darwin_arm64"
artifacts:
paths:
- featurebase_darwin_arm64
# package for linux amd64:
# stage: build
# image: golang:$GOVERSION
# rules:
# - if: '$CI_PIPELINE_SOURCE == "push"'
# variables:
# GOOS: "linux"
# GOARCH: "amd64"
# script:
# - echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | tee /etc/apt/sources.list.d/goreleaser.list
# - apt update && apt install nfpm
# - make package
# artifacts:
# paths:
# - "*.deb"
# - "*.rpm"
package for linux amd64:
stage: build
image: golang:$GOVERSION
rules:
- if: '$CI_PIPELINE_SOURCE == "push"'
variables:
GOOS: "linux"
GOARCH: "amd64"
script:
- echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | tee /etc/apt/sources.list.d/goreleaser.list
- apt update && apt install nfpm
- make package
artifacts:
paths:
- "*.deb"
- "*.rpm"
# Build a FB Docker image with CI/CD and push to the GitLab registry.
# build container fb:
# image: docker:stable
# stage: build
# needs:
# - "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:
# - tag=${CI_REGISTRY_IMAGE}/server:${CI_COMMIT_REF_SLUG}
# - docker build --build-arg GO_VERSION=$GOVERSION -t $tag -f .gitlab/Dockerfile .
# - docker push $tag
# - echo Created docker featurebase image with tag "$tag"
build container fb:
image: docker:stable
stage: build
needs:
- "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:
- tag=${CI_REGISTRY_IMAGE}/server:${CI_COMMIT_REF_SLUG}
- docker build --build-arg GO_VERSION=$GOVERSION -t $tag -f .gitlab/Dockerfile .
- docker push $tag
- echo Created docker featurebase image with tag "$tag"
# deploy EC2 instance, configure and run featurebase
# deploy node for linux amd64:
# stage: integration
# image: registry.gitlab.com/gitlab-org/cloud-deploy/aws-base:latest
# 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
# - aws configure set region "us-east-2"
# - aws configure set aws_profile $PROFILE
# - echo $AWS_SSH_PRIVATE_KEY > gitlab-featurebase-dev.pem
# - chmod 400 gitlab-featurebase-dev.pem
# - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
# - eval `ssh-agent -s`
# - mkdir -p ~/.ssh
# - echo "$AWS_SSH_PRIVATE_KEY" | ssh-add -
# - chmod 700 /root/.ssh
# - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
# - apt update && apt -y install jq
# script:
# - ./qa/scripts/deployNode.sh $PROFILE
# needs:
# - job: build for linux amd64
deploy node for linux amd64:
stage: integration
image: registry.gitlab.com/gitlab-org/cloud-deploy/aws-base:latest
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
- aws configure set region "us-east-2"
- aws configure set aws_profile $PROFILE
- echo $AWS_SSH_PRIVATE_KEY > gitlab-featurebase-dev.pem
- chmod 400 gitlab-featurebase-dev.pem
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- eval `ssh-agent -s`
- mkdir -p ~/.ssh
- echo "$AWS_SSH_PRIVATE_KEY" | ssh-add -
- chmod 700 /root/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- apt update && apt -y install jq
script:
- ./qa/scripts/deployNode.sh $PROFILE
needs:
- job: build for linux amd64
gauntlet:
stage: gauntlet
@ -257,8 +255,8 @@ gauntlet:
AWS_ACCESS_KEY_ID: $AWS_FBCI_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_FBCI_SECRET_ACCESS_KEY
# TODO: For now, run always
# rules:
# - if: '$CI_PIPELINE_SOURCE == "schedule" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
before_script:
- apt-get update && apt-get install -y gnupg software-properties-common curl git
- curl -fsSL https://apt.releases.hashicorp.com/gpg | apt-key add -