Skip to content

ci: fmt, lint and build offlinedocs #8642

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 43 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
4180d5c
build: lint offlinedocs with `make lint/ts`
matifali Jul 21, 2023
64bb4f8
add fmt and fix directories
matifali Jul 21, 2023
94b76ca
Update package.json
matifali Jul 24, 2023
028d4f0
Discard changes to offlinedocs/yarn.lock
matifali Jul 24, 2023
a0ea2a6
fix
matifali Jul 24, 2023
d249f04
Merge remote-tracking branch 'origin/main' into matifali/lint-offline…
matifali Jul 24, 2023
8eb0c91
sync
matifali Jul 24, 2023
32c50c5
install prettier for offlinedocs
matifali Jul 24, 2023
c55348c
do not freeze lockfile
matifali Jul 24, 2023
7b03589
clean up ci
matifali Jul 24, 2023
1bdfcee
cleanup
matifali Jul 24, 2023
64700c8
add seperate workflow for offlinedocs
matifali Jul 24, 2023
0fcf60c
Discard changes to Makefile
matifali Jul 24, 2023
f5532f8
move oflinedocs to docs
matifali Jul 24, 2023
052202d
refactor
matifali Jul 24, 2023
612a999
clean up yarn.lock
matifali Jul 24, 2023
17cb2b8
use env for node version
matifali Jul 24, 2023
1639b93
merge into a single job
matifali Jul 24, 2023
c276c6f
move back to ci.yaml
matifali Jul 24, 2023
1773d53
condition lint and fmt on offlinedocs-only
matifali Jul 24, 2023
4ba3f3f
use the same action with input
matifali Jul 24, 2023
c80c750
rename job
matifali Jul 24, 2023
8d6cf6f
fix script directory
matifali Jul 24, 2023
ea2f45f
fix path
matifali Jul 24, 2023
83c5e89
fixup
matifali Jul 24, 2023
f140229
install prettier
matifali Jul 24, 2023
f74f495
revert
matifali Jul 24, 2023
1a56086
move prettier to dev
matifali Jul 24, 2023
4f57bbf
fixup
matifali Jul 24, 2023
b7fd11a
prettier is not being pretty
matifali Jul 24, 2023
35cfbc4
prettier again
matifali Jul 24, 2023
88c48ad
test
matifali Jul 24, 2023
b644c5c
test
matifali Jul 24, 2023
468858a
test 2
matifali Jul 24, 2023
37b2e0a
test 3
matifali Jul 24, 2023
5fe55c1
install prettier globally
matifali Jul 24, 2023
9f2157e
fix path
matifali Jul 24, 2023
7083e55
try again
matifali Jul 24, 2023
290e52a
setp sqlc and Go
matifali Jul 24, 2023
f60bb9a
add mockgen
matifali Jul 24, 2023
a0001a5
Update .github/workflows/ci.yaml
matifali Jul 24, 2023
60445f7
Update ci.yaml
matifali Jul 24, 2023
b63ed5a
refactor
matifali Jul 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/actions/setup-node/action.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: "Setup Node"
description: |
Sets up the node environment for tests, builds, etc.
inputs:
directory:
description: |
The directory to run the setup in.
required: false
default: "site"
runs:
using: "composite"
steps:
Expand All @@ -10,8 +16,8 @@ runs:
node-version: 16.20.1
# See https://github.com/actions/setup-node#caching-global-packages-data
cache: "yarn"
cache-dependency-path: "site/yarn.lock"
cache-dependency-path: ${{ inputs.directory }}/yarn.lock
- name: Install node_modules
shell: bash
run: ../scripts/yarn_install.sh
working-directory: site
working-directory: ${{ inputs.directory }}
71 changes: 69 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ jobs:
ts: ${{ steps.filter.outputs.ts }}
k8s: ${{ steps.filter.outputs.k8s }}
ci: ${{ steps.filter.outputs.ci }}
offlinedocs-only: ${{ steps.filter.outputs.offlinedocs_count == steps.filter.outputs.all_count }}
offlinedocs: ${{ steps.filter.outputs.offlinedocs }}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will skip lint and format when we only target offlinedocs.
lint and fmt checks do not check offline docs so this was useless here

steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -85,7 +87,6 @@ jobs:
ts:
- "site/**"
- "Makefile"
- "offlinedocs/**"
k8s:
- "helm/**"
- "scripts/Dockerfile"
Expand All @@ -94,11 +95,16 @@ jobs:
ci:
- ".github/actions/**"
- ".github/workflows/ci.yaml"
offlinedocs:
- "offlinedocs/**"

- id: debug
run: |
echo "${{ toJSON(steps.filter )}}"

lint:
needs: changes
if: needs.changes.outputs.offlinedocs-only == 'false' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
steps:
- name: Checkout
Expand Down Expand Up @@ -196,6 +202,8 @@ jobs:
run: ./scripts/check_unstaged.sh

fmt:
needs: changes
if: needs.changes.outputs.offlinedocs-only == 'false' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
timeout-minutes: 5
steps:
Expand Down Expand Up @@ -592,9 +600,68 @@ jobs:
projectToken: 695c25b6cb65
workingDir: "./site"

offlinedocs:
name: offlinedocs
needs: changes
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
if: needs.changes.outputs.offlinedocs == 'true' || needs.changes.outputs.ci == 'true'
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Node
uses: ./.github/actions/setup-node
with:
directory: offlinedocs

- name: Setup Go
uses: ./.github/actions/setup-go

- name: Install go tools
run: |
go install github.com/golang/mock/mockgen@v1.6.0

- name: Setup sqlc
uses: sqlc-dev/setup-sqlc@v3
with:
sqlc-version: "1.19.1"

- name: Install dependencies
run: |
cd offlinedocs
yarn
# Install prettier globally
prettier_version=$(jq -r '.devDependencies.prettier' < package.json)
yarn global add "prettier@${prettier_version}"

- name: Format
run: |
cd offlinedocs
yarn format:check

- name: Lint
run: |
cd offlinedocs
yarn lint

- name: Build
run: |
version="$(./scripts/version.sh)"
make -j build/coder_docs_"$version".tgz

required:
runs-on: ubuntu-latest
needs: [fmt, lint, gen, test-go, test-go-pg, test-go-race, test-js]
needs:
- fmt
- lint
- gen
- test-go
- test-go-pg
- test-go-race
- test-js
- offlinedocs
# Allow this job to run even if the needed jobs fail, are skipped or
# cancelled.
if: always()
Expand Down
10 changes: 9 additions & 1 deletion offlinedocs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
"build": "next build",
"start": "next start",
"export": "yarn copy-images && next build && next export",
"copy-images": "sh ./scripts/copyImages.sh"
"copy-images": "sh ./scripts/copyImages.sh",
"lint": "yarn run lint:types",
"lint:fix": "FIX=true yarn lint",
"lint:types": "tsc --noEmit",
"format:check": "prettier --cache --check './**/*.{css,html,js,json,jsx,md,ts,tsx,yaml,yml}'",
"format:write": "prettier --cache --write './**/*.{css,html,js,json,jsx,md,ts,tsx,yaml,yml}'"
},
"dependencies": {
"@chakra-ui/react": "2.8.0",
Expand All @@ -27,11 +32,14 @@
"remark-gfm": "3.0.1"
},
"devDependencies": {
"@react-native-community/eslint-config": "^3.2.0",
"@react-native-community/eslint-plugin": "^1.3.0",
"@types/node": "18.0.0",
"@types/react": "18.0.14",
"@types/react-dom": "18.0.5",
"eslint": "8.45.0",
"eslint-config-next": "13.4.10",
"prettier": "3.0.0",
"typescript": "4.7.3"
}
}
Loading