Skip to content

Commit 757ea68

Browse files
ci: fmt, lint and build offlinedocs (#8642)
Co-authored-by: Dean Sheather <dean@deansheather.com>
1 parent 87f07b9 commit 757ea68

File tree

4 files changed

+942
-671
lines changed

4 files changed

+942
-671
lines changed
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
name: "Setup Node"
22
description: |
33
Sets up the node environment for tests, builds, etc.
4+
inputs:
5+
directory:
6+
description: |
7+
The directory to run the setup in.
8+
required: false
9+
default: "site"
410
runs:
511
using: "composite"
612
steps:
@@ -10,8 +16,8 @@ runs:
1016
node-version: 16.20.1
1117
# See https://github.com/actions/setup-node#caching-global-packages-data
1218
cache: "yarn"
13-
cache-dependency-path: "site/yarn.lock"
19+
cache-dependency-path: ${{ inputs.directory }}/yarn.lock
1420
- name: Install node_modules
1521
shell: bash
1622
run: ../scripts/yarn_install.sh
17-
working-directory: site
23+
working-directory: ${{ inputs.directory }}

.github/workflows/ci.yaml

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ jobs:
3535
ts: ${{ steps.filter.outputs.ts }}
3636
k8s: ${{ steps.filter.outputs.k8s }}
3737
ci: ${{ steps.filter.outputs.ci }}
38+
offlinedocs-only: ${{ steps.filter.outputs.offlinedocs_count == steps.filter.outputs.all_count }}
39+
offlinedocs: ${{ steps.filter.outputs.offlinedocs }}
3840
steps:
3941
- name: Checkout
4042
uses: actions/checkout@v3
@@ -85,7 +87,6 @@ jobs:
8587
ts:
8688
- "site/**"
8789
- "Makefile"
88-
- "offlinedocs/**"
8990
k8s:
9091
- "helm/**"
9192
- "scripts/Dockerfile"
@@ -94,11 +95,16 @@ jobs:
9495
ci:
9596
- ".github/actions/**"
9697
- ".github/workflows/ci.yaml"
98+
offlinedocs:
99+
- "offlinedocs/**"
100+
97101
- id: debug
98102
run: |
99103
echo "${{ toJSON(steps.filter )}}"
100104
101105
lint:
106+
needs: changes
107+
if: needs.changes.outputs.offlinedocs-only == 'false' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
102108
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
103109
steps:
104110
- name: Checkout
@@ -194,6 +200,8 @@ jobs:
194200
run: ./scripts/check_unstaged.sh
195201

196202
fmt:
203+
needs: changes
204+
if: needs.changes.outputs.offlinedocs-only == 'false' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
197205
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
198206
timeout-minutes: 5
199207
steps:
@@ -590,9 +598,68 @@ jobs:
590598
projectToken: 695c25b6cb65
591599
workingDir: "./site"
592600

601+
offlinedocs:
602+
name: offlinedocs
603+
needs: changes
604+
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
605+
if: needs.changes.outputs.offlinedocs == 'true' || needs.changes.outputs.ci == 'true'
606+
steps:
607+
- name: Checkout
608+
uses: actions/checkout@v3
609+
with:
610+
fetch-depth: 0
611+
612+
- name: Setup Node
613+
uses: ./.github/actions/setup-node
614+
with:
615+
directory: offlinedocs
616+
617+
- name: Setup Go
618+
uses: ./.github/actions/setup-go
619+
620+
- name: Install go tools
621+
run: |
622+
go install github.com/golang/mock/mockgen@v1.6.0
623+
624+
- name: Setup sqlc
625+
uses: sqlc-dev/setup-sqlc@v3
626+
with:
627+
sqlc-version: "1.19.1"
628+
629+
- name: Install dependencies
630+
run: |
631+
cd offlinedocs
632+
yarn
633+
# Install prettier globally
634+
prettier_version=$(jq -r '.devDependencies.prettier' < package.json)
635+
yarn global add "prettier@${prettier_version}"
636+
637+
- name: Format
638+
run: |
639+
cd offlinedocs
640+
yarn format:check
641+
642+
- name: Lint
643+
run: |
644+
cd offlinedocs
645+
yarn lint
646+
647+
- name: Build
648+
run: |
649+
version="$(./scripts/version.sh)"
650+
make -j build/coder_docs_"$version".tgz
651+
593652
required:
594653
runs-on: ubuntu-latest
595-
needs: [fmt, lint, gen, test-go, test-go-pg, test-go-race, test-js]
654+
needs:
655+
- fmt
656+
- lint
657+
- gen
658+
- test-go
659+
- test-go-pg
660+
- test-go-race
661+
- test-js
662+
- offlinedocs
596663
# Allow this job to run even if the needed jobs fail, are skipped or
597664
# cancelled.
598665
if: always()

offlinedocs/package.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@
77
"build": "next build",
88
"start": "next start",
99
"export": "yarn copy-images && next build && next export",
10-
"copy-images": "sh ./scripts/copyImages.sh"
10+
"copy-images": "sh ./scripts/copyImages.sh",
11+
"lint": "yarn run lint:types",
12+
"lint:fix": "FIX=true yarn lint",
13+
"lint:types": "tsc --noEmit",
14+
"format:check": "prettier --cache --check './**/*.{css,html,js,json,jsx,md,ts,tsx,yaml,yml}'",
15+
"format:write": "prettier --cache --write './**/*.{css,html,js,json,jsx,md,ts,tsx,yaml,yml}'"
1116
},
1217
"dependencies": {
1318
"@chakra-ui/react": "2.8.0",
@@ -27,11 +32,14 @@
2732
"remark-gfm": "3.0.1"
2833
},
2934
"devDependencies": {
35+
"@react-native-community/eslint-config": "^3.2.0",
36+
"@react-native-community/eslint-plugin": "^1.3.0",
3037
"@types/node": "18.0.0",
3138
"@types/react": "18.0.14",
3239
"@types/react-dom": "18.0.5",
3340
"eslint": "8.45.0",
3441
"eslint-config-next": "13.4.10",
42+
"prettier": "3.0.0",
3543
"typescript": "4.7.3"
3644
}
3745
}

0 commit comments

Comments
 (0)