3.6 KB98 lines
Blame
1name: Lint
2
3on:
4 push:
5 merge_group:
6 pull_request:
7 workflow_dispatch:
8
9concurrency: ${{ github.workflow }}-${{ github.ref }}
10
11permissions:
12 contents: write
13
14jobs:
15 docker-lint:
16 runs-on: ubuntu-latest
17 steps:
18 - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
19
20 - uses: hadolint/hadolint-action@54c9adbab1582c2ef04b2016b760714a4bfde3cf # v3.1.0
21 with:
22 verbose: true
23 lint:
24 runs-on: ubuntu-latest
25 steps:
26 - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
27
28 - uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
29 # uses version from "packageManager" field in package.json
30
31 - name: Setup Node.js
32 uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
33 with:
34 cache: pnpm
35 node-version-file: '.node-version'
36
37 - name: Install Packages
38 run: |
39 pnpm install --frozen-lockfile
40 env:
41 CYPRESS_CACHE_FOLDER: .cache/Cypress
42
43 - name: Run Linting
44 shell: bash
45 run: |
46 if ! pnpm run lint; then
47 # print a nice error message on lint failure
48 ERROR_MESSAGE='Running `pnpm run lint` failed.'
49 ERROR_MESSAGE+=' Running `pnpm -w run lint:fix` may fix this issue. '
50 ERROR_MESSAGE+=" If this error doesn't occur on your local machine,"
51 ERROR_MESSAGE+=' make sure your packages are up-to-date by running `pnpm install`.'
52 ERROR_MESSAGE+=' You may also need to delete your prettier cache by running'
53 ERROR_MESSAGE+=' `rm ./node_modules/.cache/prettier/.prettier-cache`.'
54 echo "::error title=Lint failure::${ERROR_MESSAGE}"
55 # make sure to return an error exitcode so that GitHub actions shows a red-cross
56 exit 1
57 fi
58
59 - name: Verify `./src/config.type.ts` is in sync with `./src/schemas/config.schema.yaml`
60 shell: bash
61 run: |
62 if ! pnpm run --filter mermaid types:verify-config; then
63 ERROR_MESSAGE='Running `pnpm run --filter mermaid types:verify-config` failed.'
64 ERROR_MESSAGE+=' This should be fixed by running'
65 ERROR_MESSAGE+=' `pnpm run --filter mermaid types:build-config`'
66 ERROR_MESSAGE+=' on your local machine.'
67 echo "::error title=Lint failure::${ERROR_MESSAGE}"
68 # make sure to return an error exitcode so that GitHub actions shows a red-cross
69 exit 1
70 fi
71
72 - name: Verify no circular dependencies
73 working-directory: ./packages/mermaid
74 shell: bash
75 run: |
76 if ! pnpm run --filter mermaid checkCircle; then
77 ERROR_MESSAGE='Circular dependency detected.'
78 ERROR_MESSAGE+=' This should be fixed by removing the circular dependency.'
79 ERROR_MESSAGE+=' Run `pnpm run --filter mermaid checkCircle` on your local machine'
80 ERROR_MESSAGE+=' to see the circular dependency.'
81 echo "::error title=Lint failure::${ERROR_MESSAGE}"
82 # make sure to return an error exitcode so that GitHub actions shows a red-cross
83 exit 1
84 fi
85
86 - name: Verify Docs
87 id: verifyDocs
88 working-directory: ./packages/mermaid
89 continue-on-error: ${{ github.event_name == 'push' }}
90 run: pnpm run docs:verify
91
92 - uses: testomatio/check-tests@0ea638fcec1820cf2e7b9854fdbdd04128a55bd4 # stable
93 with:
94 framework: cypress
95 tests: './cypress/e2e/**/**.spec.js'
96 token: ${{ secrets.GITHUB_TOKEN }}
97 has-tests-label: true
98