Skip to content

Commit

Permalink
try 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Lev Brouk committed Aug 16, 2022
1 parent cda3058 commit 027b11c
Showing 1 changed file with 102 additions and 99 deletions.
201 changes: 102 additions & 99 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@ executors:
- image: cimg/go:1.18.3

aliases:
- &restore_go_cache
restore_cache:
key: go-mod-v2-{{ checksum "go.sum" }}
- &save_go_cache
save_cache:
key: go-mod-v2-{{ checksum "go.sum" }}
paths:
- "/go/pkg/mod"
- &restore_cypress_cache
restore_cache:
key: cypress-cache-{{ checksum "test/e2e/package-lock.json" }}
- &save_cypress_cache
save_cache:
key: cypress-cache-{{ checksum "test/e2e/package-lock.json" }}
paths:
- ./test/e2e/node_modules
- /home/circleci/.cache/Cypress
- &restore_go_cache
restore_cache:
key: go-mod-v3-{{ checksum "go.sum" }}
- &save_go_cache
save_cache:
key: go-mod-v3-{{ checksum "go.sum" }}
paths:
- "~/go/pkg/mod"
- &restore_cypress_cache
restore_cache:
key: cypress-cache-{{ checksum "test/e2e/package-lock.json" }}
- &save_cypress_cache
save_cache:
key: cypress-cache-{{ checksum "test/e2e/package-lock.json" }}
paths:
- ./test/e2e/node_modules
- /home/circleci/.cache/Cypress

commands:
deploy:
Expand All @@ -39,79 +39,64 @@ commands:
- aws-s3/copy:
from: << parameters.filename >>
to: << parameters.bucket >>
arguments: '--acl public-read --cache-control no-cache'
arguments: "--acl public-read --cache-control no-cache"

install-golangci-lint:
description: Install golangci-lint
parameters:
version:
type: string
default: 1.46.1
gobin:
type: string
default: $GOPATH/bin
prefix:
type: string
default: v2
description: Prefix for cache key to store the binary.
steps:
- restore_cache:
name: Restore golangci-lint cache
keys: ['<< parameters.prefix >>-golangci-lint-{{ arch }}-<< parameters.version >>']
- run:
name: Install golangci-lint
command: |
mkdir -p << parameters.gobin >>
command -v << parameters.gobin >>/golangci-lint && exit
download=https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh
wget -O- -q $download | sh -s -- -b << parameters.gobin >>/ v<< parameters.version >>
- save_cache:
name: Save golangci-lint cache
key: '<< parameters.prefix >>-golangci-lint-{{ arch }}-<< parameters.version >>'
paths: [<< parameters.gobin >>/golangci-lint]
# install-golangci-lint:
# description: Install golangci-lint
# parameters:
# version:
# type: string
# default: 1.46.1
# gobin:
# type: string
# default: $GOPATH/bin
# prefix:
# type: string
# default: v2
# description: Prefix for cache key to store the binary.
# steps:
# - restore_cache:
# name: Restore golangci-lint cache
# keys: ['<< parameters.prefix >>-golangci-lint-{{ arch }}-<< parameters.version >>']
# - run:
# name: Install golangci-lint
# command: |
# mkdir -p << parameters.gobin >>
# command -v << parameters.gobin >>/golangci-lint && exit
# download=https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh
# wget -O- -q $download | sh -s -- -b << parameters.gobin >>/ v<< parameters.version >>
# - save_cache:
# name: Save golangci-lint cache
# key: '<< parameters.prefix >>-golangci-lint-{{ arch }}-<< parameters.version >>'
# paths: [<< parameters.gobin >>/golangci-lint]

jobs:
check-mocks:
lint:
executor:
name: default
resource_class: large
steps:
- checkout
- *restore_go_cache
- run:
name: Checking code style
command: make check-style
- run:
name: Checking diff of go mod files
command: |
go mod tidy -v
git --no-pager diff --exit-code go.mod go.sum || (echo "Please run \"go mod tidy\" and commit the changes in go.mod and go.sum." && exit 1)
- run:
name: Checking if generated mocks are up to date
command: |
make mock
git --no-pager diff --exit-code server/mocks* || (echo "Please run \"make mock\" and commit the changes in the generated files." && exit 1)
- *save_go_cache

check-i18n:
executor:
name: default
steps:
- checkout
- run:
name: Checking if extracted i18n files are up to date
command: |
go install github.com/nicksnyder/go-i18n/v2/goi18n@v2.2.0
make i18n-extract-server
git --no-pager diff --exit-code assets/i18n/* || (echo "Please run \"make i18n-extract-server\" and commit the changes in the generated files." && exit 1)
lint:
executor:
name: default
resource_class: large
steps:
- checkout
- *restore_go_cache
- install-golangci-lint
- run:
name: Checking code style
command: make check-style
- run: go mod tidy -v
- run:
name: Checking diff of go mod files
command: |
git --no-pager diff --exit-code go.mod go.sum || (echo "Please run \"go mod tidy\" and commit the changes in go.mod and go.sum." && exit 1)
- *save_go_cache

test:
Expand All @@ -134,9 +119,9 @@ jobs:
command: make coverage
- *save_go_cache
- codecov/upload:
file: server/coverage.txt
file: server/coverage.txt

build:
dist:
executor:
name: default
steps:
Expand Down Expand Up @@ -415,7 +400,7 @@ jobs:
steps:
- attach_workspace:
at: dist
- run: 'mv dist/*.tar.gz dist/$CIRCLE_PROJECT_REPONAME-ci.tar.gz'
- run: "mv dist/*.tar.gz dist/$CIRCLE_PROJECT_REPONAME-ci.tar.gz"
- deploy:
filename: "dist/*.tar.gz"
bucket: "s3://mattermost-plugins-ci/ci/"
Expand All @@ -442,42 +427,62 @@ workflows:
only:
- master
jobs:
- check-mocks
- check-i18n
- lint
- test
- build
- e2e-cypress-tests-pinned
- e2e-cypress-tests-master
- test-rest-postgres11
- test:
requires:
- lint
- dist:
requires:
- test
- e2e-cypress-tests-pinned:
requires:
- dist
- e2e-cypress-tests-master:
requires:
- dist
- test-rest-postgres11:
requires:
- test

ci:
jobs:
- check-mocks:
filters:
tags:
only: /^v.*/
- check-i18n:
- lint:
filters:
tags:
only: /^v.*/
- lint:
- test:
requires:
- lint
filters:
tags:
only: /^v.*/
- coverage:
- dist:
requires:
- test
filters:
tags:
only: /^v.*/
- test-rest-postgres11:
- e2e-cypress-tests-pinned:
requires:
- dist
filters:
tags:
only: /^v.*/
- e2e-cypress-tests-pinned
- e2e-cypress-tests-master:
filters:
branches:
only: master
- build:
requires:
- dist
- test-rest-postgres11:
requires:
- test
filters:
tags:
only: /^v.*/
- coverage:
requires:
- test
filters:
tags:
only: /^v.*/
Expand All @@ -487,14 +492,12 @@ workflows:
only: master
context: plugin-ci
requires:
- check-mocks
- check-i18n
- lint
- test
- coverage
- test-rest-postgres11
- e2e-cypress-tests-pinned
- e2e-cypress-tests-master
- build
- dist
- deploy-release-github:
filters:
tags:
Expand All @@ -503,9 +506,9 @@ workflows:
ignore: /.*/
context: matterbuild-github-token
requires:
- check-mocks
- check-i18n
- lint
- test
- coverage
- test-rest-postgres11
- build
- e2e-cypress-tests-pinned
- e2e-cypress-tests-master
- dist

0 comments on commit 027b11c

Please sign in to comment.