|
| 1 | +version: 2.1 |
| 2 | +orbs: |
| 3 | + |
| 4 | + commitlint: conventional-changelog/[email protected] |
| 5 | + |
| 6 | +parameters: |
| 7 | + rebuild_cache: |
| 8 | + type: boolean |
| 9 | + default: false |
| 10 | + |
| 11 | +# Extra contexts to expose to all jobs below |
| 12 | +contexts: &contexts |
| 13 | + - aws-credentials |
| 14 | + - ghaccesstoken |
| 15 | + - docker-registry |
| 16 | + - npm-credentials |
| 17 | + - vault-dev |
| 18 | + - confluence |
| 19 | + - circleci-credentials |
| 20 | + - tray-webhooks |
| 21 | + |
| 22 | +# Configuration to pass to test and cache jobs |
| 23 | +cfg: &cfg |
| 24 | + context: *contexts |
| 25 | + |
| 26 | +# Branches used for releasing code, pre-release or not |
| 27 | +release_branches: &release_branches |
| 28 | + - "main" |
| 29 | + |
| 30 | +executors: |
| 31 | + commitlint-executor: |
| 32 | + docker: |
| 33 | + - image: cimg/node:current |
| 34 | + working_directory: ~/project |
| 35 | + |
| 36 | +jobs: |
| 37 | + test: |
| 38 | + executor: |
| 39 | + name: go/default # Use the default executor from the orb |
| 40 | + tag: "1.22.2" # Specify a version tag |
| 41 | + steps: |
| 42 | + - checkout # checkout source code |
| 43 | + - go/load-cache # Load cached Go modules. |
| 44 | + - go/mod-download # Run 'go mod download'. |
| 45 | + - go/save-cache # Save Go modules to cache. |
| 46 | + - run: |
| 47 | + name: Run unit tests |
| 48 | + command: make test |
| 49 | + - run: |
| 50 | + name: Run integration tests |
| 51 | + command: make integration-test |
| 52 | + release: |
| 53 | + docker: |
| 54 | + - image: cimg/go:1.20 |
| 55 | + steps: |
| 56 | + - run: curl -sL https://git.io/autotag-install | sudo sh -s -- -b /usr/bin |
| 57 | + - checkout |
| 58 | + - run: autotag --scheme=conventional |
| 59 | + - run: curl -sfL https://goreleaser.com/static/run | bash |
| 60 | + setup-commitlint: |
| 61 | + executor: commitlint-executor |
| 62 | + steps: |
| 63 | + - checkout |
| 64 | + - restore_cache: |
| 65 | + key: lock-{{ checksum "package-lock.json" }} |
| 66 | + - run: |
| 67 | + name: Install dependencies |
| 68 | + command: npm install |
| 69 | + - save_cache: |
| 70 | + key: lock-{{ checksum "package-lock.json" }} |
| 71 | + paths: |
| 72 | + - node_modules |
| 73 | + - persist_to_workspace: |
| 74 | + root: ~/project |
| 75 | + paths: |
| 76 | + - node_modules |
| 77 | + lint-commit: |
| 78 | + executor: commitlint-executor |
| 79 | + steps: |
| 80 | + - checkout |
| 81 | + - attach_workspace: |
| 82 | + at: ~/project |
| 83 | + - run: |
| 84 | + name: Define environment variable with latest commit's message |
| 85 | + command: | |
| 86 | + echo 'export COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s")' >> $BASH_ENV |
| 87 | + source $BASH_ENV |
| 88 | + - run: |
| 89 | + name: Lint commit message |
| 90 | + command: echo "$COMMIT_MESSAGE" | npx commitlint |
| 91 | + check-initial-tag: |
| 92 | + docker: |
| 93 | + - image: cimg/base:stable |
| 94 | + steps: |
| 95 | + - checkout |
| 96 | + - run: |
| 97 | + name: Check initial tag v0.0.0 |
| 98 | + command: make check-initial-tag |
| 99 | + |
| 100 | + |
| 101 | +workflows: |
| 102 | + release-version: |
| 103 | + jobs: |
| 104 | + - setup-commitlint: |
| 105 | + filters: |
| 106 | + branches: |
| 107 | + ignore: /.*/ |
| 108 | + tags: |
| 109 | + only: /v[0-9]+(\.[0-9]+)*(-.*)*/ |
| 110 | + - lint-commit: |
| 111 | + requires: |
| 112 | + - setup-commitlint |
| 113 | + # Only run this job on git tag pushes |
| 114 | + filters: |
| 115 | + branches: |
| 116 | + ignore: /.*/ |
| 117 | + tags: |
| 118 | + only: /v[0-9]+(\.[0-9]+)*(-.*)*/ |
| 119 | + - test: |
| 120 | + # Only run this job on git tag pushes |
| 121 | + filters: |
| 122 | + branches: |
| 123 | + ignore: /.*/ |
| 124 | + tags: |
| 125 | + only: /v[0-9]+(\.[0-9]+)*(-.*)*/ |
| 126 | + - check-initial-tag: |
| 127 | + # Only run this job on git tag pushes |
| 128 | + filters: |
| 129 | + branches: |
| 130 | + ignore: /.*/ |
| 131 | + tags: |
| 132 | + only: /v[0-9]+(\.[0-9]+)*(-.*)*/ |
| 133 | + - release: |
| 134 | + # Only run this job on git tag pushes |
| 135 | + requires: |
| 136 | + - lint-commit |
| 137 | + - test |
| 138 | + - check-initial-tag |
| 139 | + filters: |
| 140 | + branches: |
| 141 | + ignore: /.*/ |
| 142 | + tags: |
| 143 | + only: /v[0-9]+(\.[0-9]+)*(-.*)*/ |
| 144 | + |
| 145 | + branch: |
| 146 | + jobs: |
| 147 | + - setup-commitlint |
| 148 | + - lint-commit: |
| 149 | + requires: |
| 150 | + - setup-commitlint |
| 151 | + - test: |
| 152 | + filters: |
| 153 | + branches: |
| 154 | + ignore: main |
| 155 | + tags: |
| 156 | + ignore: /.*/ |
0 commit comments