diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 0ae2e36b2..000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,210 +0,0 @@ -version: 2.1 - -orbs: - aws-s3: circleci/aws-s3@1.0.16 - codecov: codecov/codecov@1.1.1 - -executors: - default: - docker: - - image: cimg/go:1.18.8@sha256:a65231064cf5806b7cb2a2243cbcf4eb4415b13554d8626e65b9d624b957675e - -commands: - install-node-npm: - description: Install Node.js and npm - steps: - - run: - name: "Install Node.js and npm" - command: | - curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash - export NVM_DIR="$HOME/.nvm" - [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm - echo 'export NVM_DIR=$HOME/.nvm' >> $BASH_ENV - echo 'source $NVM_DIR/nvm.sh' >> $BASH_ENV - nvm install 16.9.1 - - run: - name: Check current version of node - command: node -v - - run: - name: Check current version of NPM - command: npm -v - - npm-dependencies: - description: "Get JavaScript dependencies" - steps: - - restore_cache: - name: Restore npm cache - key: v2-npm-{{ checksum "./webapp/package-lock.json" }}-{{ arch }} - - run: - name: Getting JavaScript dependencies - command: | - cd webapp - NODE_ENV=development npm ci --ignore-scripts --no-save - - save_cache: - name: Save npm cache - key: v2-npm-{{ checksum "./webapp/package-lock.json" }}-{{ arch }} - paths: - - ./webapp/node_modules - - npm-dependencies-standalone: - description: "Get JavaScript dependencies" - steps: - - restore_cache: - name: Restore npm cache - key: v2-npm-{{ checksum "./standalone/package-lock.json" }}-{{ arch }} - - run: - name: Getting JavaScript dependencies - command: | - cd standalone - NODE_ENV=development npm ci --ignore-scripts --no-save - - save_cache: - name: Save npm cache - key: v2-npm-{{ checksum "./standalone/package-lock.json" }}-{{ arch }} - paths: - - ./standalone/node_modules - - install-golangci-lint: - description: Install golangci-lint - parameters: - version: - type: string - default: 1.50.1 - gobin: - type: string - default: /home/circleci/go/bin - prefix: - type: string - default: v1 - 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 ] - -aliases: - - &restore_cache - restore_cache: - key: go-mod-v1-{{ checksum "go.sum" }} - - &save_cache - save_cache: - key: go-mod-v1-{{ checksum "go.sum" }} - paths: - - "/home/circleci/go/pkg/mod" - -jobs: - lint: - executor: - name: default - steps: - - checkout - - install-golangci-lint - - *restore_cache - - install-node-npm - - npm-dependencies - - npm-dependencies-standalone - - 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) - - run: make apply - - run: - name: Checking diff of generated manifest files - command: | - git --no-pager diff --exit-code *manifest.* || (echo "Please run \"make apply\" and commit the changes in the generated manifests." && exit 1) - - run: make i18n-extract - - run: - name: Checking diff of i18n files - command: | - git --no-pager diff --exit-code webapp/i18n/en.json || (echo "Please run \"make i18n-extract\" and commit the changes in en.json." && exit 1) - - *save_cache - - test: - executor: - name: default - steps: - - checkout - - *restore_cache - - install-node-npm - - npm-dependencies - - npm-dependencies-standalone - - run: make test - - *save_cache - - build: - executor: - name: default - steps: - - checkout - - install-node-npm - - npm-dependencies - - npm-dependencies-standalone - - run: - name: Building Plugin Bundle - command: make dist-ci - - run: - name: Generating Release Notes - command: | - printf "Supported Mattermost Server Versions: **$(cat plugin.json | jq .min_server_version -r)+** \n## Commits\n" >> dist/release-notes.md - if [[ $(git tag -l | wc -l) -eq 1 ]]; then - git log --pretty='format:- %h %s' --abbrev-commit --no-decorate --no-color $(git rev-list --max-parents=0 HEAD) HEAD >> dist/release-notes.md - else - git log --pretty='format:- %h %s' --abbrev-commit --no-decorate --no-color $(git describe --tags --abbrev=0 $(git describe --tags --abbrev=0)^)..HEAD >> dist/release-notes.md - fi - - persist_to_workspace: - root: dist - paths: - - "*.tar.gz" - - "release-notes.md" - - store_artifacts: - path: dist - - deploy-release-github: - docker: - - image: cibuilds/github:0.13.0@sha256:2cee61741812b8ecaa53a92b0cdb3d8fea24bc7c50c9d394c055df97497857be - steps: - - attach_workspace: - at: dist - - run: - name: "Publish Release on Github" - command: | - ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -b "$(< ./dist/release-notes.md)" -c ${CIRCLE_SHA1} -n ${CIRCLE_TAG} -delete ${CIRCLE_TAG} dist/*.tar.gz - -workflows: - version: 2 - ci: - jobs: - - lint - - test - - build: - context: mattermost-plugin-calls-production - filters: - tags: - only: /^v.*/ - - deploy-release-github: - context: matterbuild-github-token - filters: - # ignore any commit on any branch by default - branches: - ignore: /.*/ - # only act on version tags - tags: - only: /^v.*/ - requires: - - lint - - test - - build diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 000000000..5d2eaa9d8 --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,17 @@ +name: cd +on: + workflow_run: + workflows: ["ci"] + types: + - completed + push: + tags: + - "v[0-9]+.[0-9]+.[0-9]+" + +permissions: + contents: read + +jobs: + plugin-cd: + uses: mattermost/actions-workflows/.github/workflows/plugin-cd.yml@main + secrets: inherit diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..753b0e818 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,19 @@ +name: ci +on: + push: + branches: + - main + tags: + - "v[0-9]+.[0-9]+.[0-9]+" + pull_request: + +permissions: + contents: read + +jobs: + plugin-ci: + uses: mattermost/actions-workflows/.github/workflows/plugin-ci.yml@main + with: + golangci-lint-version: "v1.51.2" + golang-version: "1.19" + secrets: inherit diff --git a/.golangci.yml b/.golangci.yml index 83b697f45..6395e1ba4 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,3 +1,6 @@ +service: + golangci-lint-version: 1.54.2 + run: timeout: 5m modules-download-mode: readonly @@ -44,9 +47,3 @@ linters: - unused # Checks Go code for unused constants, variables, functions and types - exportloopref # Checks for pointers to enclosing loop variables - errcheck # Detects unchecked errors. - -issues: - exclude-rules: - - linters: - - unused - text: "getConfiguration" diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 000000000..3027af39c --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +16.10.0