CLOUDP-286235: Improved tooling (ESLint/Prettier) and GH actions #932
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 'Code Health Tools' | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- 'tools/**' | |
pull_request: {} | |
workflow_dispatch: {} | |
workflow_call: {} | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout CLI | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 | |
- name: Install Go | |
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed | |
with: | |
go-version-file: 'tools/cli/go.mod' | |
- name: Build CLI | |
working-directory: tools/cli | |
run: make build | |
unit-tests: | |
needs: build | |
env: | |
COVERAGE: coverage.out | |
UNIT_TAGS: unit | |
INTEGRATION_TAGS: integration | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 | |
- name: Install Go | |
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed | |
with: | |
go-version-file: 'tools/cli/go.mod' | |
- name: Run unit tests | |
working-directory: tools/cli | |
run: make unit-test | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 | |
with: | |
sparse-checkout: | | |
.github | |
tools | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20.x' | |
- name: Install npm dependencies | |
uses: nick-fields/retry@v3 | |
with: | |
timeout_minutes: 10 | |
max_attempts: 3 | |
command: npm install | |
- name: Run Prettier | |
run: | | |
npm run format-check | |
- name: Run ESLint on JS files | |
run: | | |
npm run lint-js | |
- name: Install Go | |
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed | |
with: | |
go-version-file: 'tools/cli/go.mod' | |
cache: false # see https://github.com/golangci/golangci-lint-action/issues/807 | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 | |
with: | |
version: v1.60.3 | |
working-directory: tools/cli | |
- name: Checkout GitHub actions | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 | |
with: | |
sparse-checkout: | | |
.github | |
- name: Download actionlint | |
id: get_actionlint | |
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash) | |
shell: bash | |
- name: Check workflow files | |
run: | | |
echo "::add-matcher::.github/actionlint-matcher.json" | |
${{ steps.get_actionlint.outputs.executable }} -color | |
shell: bash | |
e2e-tests: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 | |
- name: Install Go | |
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed | |
with: | |
go-version-file: 'tools/cli/go.mod' | |
- name: Run e2e tests | |
working-directory: tools/cli | |
run: make e2e-test |