Skip to content

Commit a702446

Browse files
committedOct 16, 2024
Add more scaffolding, CI, formatting, tasks
1 parent b5daf66 commit a702446

File tree

11 files changed

+1564
-6
lines changed

11 files changed

+1564
-6
lines changed
 

‎.dprint.jsonc

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
// If updating this, also update the config in dtsBundler.mjs.
3+
"indentWidth": 4,
4+
"lineWidth": 1000,
5+
"newLineKind": "auto",
6+
"useTabs": false,
7+
"typescript": {
8+
"newLineKind": "crlf",
9+
"semiColons": "always",
10+
"quoteStyle": "preferDouble",
11+
"quoteProps": "consistent",
12+
"useBraces": "whenNotSingleLine",
13+
"bracePosition": "sameLineUnlessHanging",
14+
"singleBodyPosition": "sameLine",
15+
"nextControlFlowPosition": "nextLine", // Stroustrup style braces.
16+
"trailingCommas": "onlyMultiLine",
17+
"preferHanging": false,
18+
"operatorPosition": "maintain",
19+
20+
"arrowFunction.useParentheses": "preferNone",
21+
"conditionalExpression.linePerExpression": false, // Keep our "match/case"-ish conditionals.
22+
"functionExpression.spaceAfterFunctionKeyword": true,
23+
"importDeclaration.forceMultiLine": "whenMultiple",
24+
"constructorType.spaceAfterNewKeyword": true,
25+
"constructSignature.spaceAfterNewKeyword": true,
26+
27+
"module.sortImportDeclarations": "caseInsensitive",
28+
"module.sortExportDeclarations": "caseInsensitive",
29+
"exportDeclaration.sortNamedExports": "caseInsensitive",
30+
"importDeclaration.sortNamedImports": "caseInsensitive"
31+
},
32+
"yaml": {
33+
"indentWidth": 2,
34+
"quotes": "preferSingle"
35+
},
36+
"json": {
37+
// This would be good to do in known-JSONC files, but VS Code warns on trailing commas.
38+
"trailingCommas": "never"
39+
},
40+
"exec": {
41+
"cwd": "${configDir}",
42+
"commands": [
43+
{ "command": "gofmt", "exts": ["go"] }
44+
]
45+
},
46+
"excludes": [
47+
"**/.git",
48+
"**/node_modules",
49+
"**/*-lock.json",
50+
"**/testdata",
51+
"_submodules/**"
52+
],
53+
// Note: if adding new languages, make sure settings.template.json is updated too.
54+
// Also, if updating typescript, update the one in package.json.
55+
"plugins": [
56+
"https://plugins.dprint.dev/typescript-0.93.0.wasm",
57+
"https://plugins.dprint.dev/json-0.19.3.wasm",
58+
"https://plugins.dprint.dev/g-plane/pretty_yaml-v0.5.0.wasm",
59+
"https://plugins.dprint.dev/exec-0.5.0.json@8d9972eee71fa1590e04873540421f3eda7674d0f1aae3d7c788615e7b7413d0"
60+
]
61+
}

‎.github/workflows/ci.yml

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
permissions:
12+
contents: read
13+
14+
# Ensure scripts are run with pipefail. See:
15+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference
16+
defaults:
17+
run:
18+
shell: bash
19+
20+
jobs:
21+
build:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
25+
- uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
26+
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
27+
with:
28+
go-version: '>=1.23.0'
29+
30+
- run: npm ci
31+
32+
- run: npx hereby build
33+
34+
test:
35+
strategy:
36+
fail-fast: false
37+
matrix:
38+
os:
39+
- ubuntu-latest
40+
- windows-latest
41+
- macos-latest
42+
43+
runs-on: ${{ matrix.os }}
44+
45+
steps:
46+
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
47+
with:
48+
submodules: true
49+
- uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
50+
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
51+
with:
52+
go-version: '>=1.23.0'
53+
54+
- run: npm ci
55+
56+
- run: npx hereby test
57+
58+
lint:
59+
runs-on: ubuntu-latest
60+
steps:
61+
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
62+
- uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
63+
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
64+
with:
65+
go-version: '>=1.23.0'
66+
67+
- run: npm ci
68+
69+
- run: npx hereby lint
70+
71+
format:
72+
runs-on: ubuntu-latest
73+
steps:
74+
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
75+
- uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
76+
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
77+
with:
78+
go-version: '>=1.23.0'
79+
80+
- run: npm ci
81+
82+
- run: npx hereby check:format
83+
84+
generate:
85+
runs-on: ubuntu-latest
86+
steps:
87+
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
88+
with:
89+
submodules: true
90+
- uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
91+
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
92+
with:
93+
go-version: '>=1.23.0'
94+
95+
- run: npm ci
96+
97+
- run: npx hereby generate
98+
99+
- run: git diff --exit-code
100+
101+
tidy:
102+
runs-on: ubuntu-latest
103+
steps:
104+
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
105+
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
106+
with:
107+
go-version: '>=1.23.0'
108+
109+
- run: go mod tidy
110+
111+
- run: git diff --exit-code
112+
113+
required:
114+
runs-on: ubuntu-latest
115+
if: ${{ always() }}
116+
needs:
117+
- build
118+
- test
119+
- lint
120+
- format
121+
- generate
122+
123+
steps:
124+
- name: Check required jobs
125+
env:
126+
NEEDS: ${{ toJson(needs) }}
127+
run: |
128+
! echo $NEEDS | jq -e 'to_entries[] | { job: .key, result: .value.result } | select(.result != "success")'

‎.gitignore

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,134 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
.pnpm-debug.log*
9+
10+
# Diagnostic reports (https://nodejs.org/api/report.html)
11+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
12+
13+
# Runtime data
14+
pids
15+
*.pid
16+
*.seed
17+
*.pid.lock
18+
19+
# Directory for instrumented libs generated by jscoverage/JSCover
20+
lib-cov
21+
22+
# Coverage directory used by tools like istanbul
23+
coverage
24+
*.lcov
25+
26+
# nyc test coverage
27+
.nyc_output
28+
29+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
30+
.grunt
31+
32+
# Bower dependency directory (https://bower.io/)
33+
bower_components
34+
35+
# node-waf configuration
36+
.lock-wscript
37+
38+
# Compiled binary addons (https://nodejs.org/api/addons.html)
39+
build/Release
40+
41+
# Dependency directories
42+
node_modules/
43+
jspm_packages/
44+
45+
# Snowpack dependency directory (https://snowpack.dev/)
46+
web_modules/
47+
48+
# TypeScript cache
49+
*.tsbuildinfo
50+
51+
# Optional npm cache directory
52+
.npm
53+
54+
# Optional eslint cache
55+
.eslintcache
56+
57+
# Optional stylelint cache
58+
.stylelintcache
59+
60+
# Microbundle cache
61+
.rpt2_cache/
62+
.rts2_cache_cjs/
63+
.rts2_cache_es/
64+
.rts2_cache_umd/
65+
66+
# Optional REPL history
67+
.node_repl_history
68+
69+
# Output of 'npm pack'
70+
*.tgz
71+
72+
# Yarn Integrity file
73+
.yarn-integrity
74+
75+
# dotenv environment variable files
76+
.env
77+
.env.development.local
78+
.env.test.local
79+
.env.production.local
80+
.env.local
81+
82+
# parcel-bundler cache (https://parceljs.org/)
83+
.cache
84+
.parcel-cache
85+
86+
# Next.js build output
87+
.next
88+
out
89+
90+
# Nuxt.js build / generate output
91+
.nuxt
92+
dist
93+
94+
# Gatsby files
95+
.cache/
96+
# Comment in the public line in if your project uses Gatsby and not Next.js
97+
# https://nextjs.org/blog/next-9-1#public-directory-support
98+
# public
99+
100+
# vuepress build output
101+
.vuepress/dist
102+
103+
# vuepress v2.x temp and cache directory
104+
.temp
105+
.cache
106+
107+
# Docusaurus cache and generated files
108+
.docusaurus
109+
110+
# Serverless directories
111+
.serverless/
112+
113+
# FuseBox cache
114+
.fusebox/
115+
116+
# DynamoDB Local files
117+
.dynamodb/
118+
119+
# TernJS port file
120+
.tern-port
121+
122+
# Stores VSCode versions used for testing VSCode extensions
123+
.vscode-test
124+
125+
# yarn v2
126+
.yarn/cache
127+
.yarn/unplugged
128+
.yarn/build-state.yml
129+
.yarn/install-state.gz
130+
.pnp.*
131+
1132
# If you prefer the allow list template instead of the deny list, see community template:
2133
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
3134
#

‎.vscode/extensions.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"recommendations": [
3+
"dprint.dprint",
4+
"golang.go"
5+
]
6+
}

‎.vscode/settings.template.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,9 @@
55
"editor.defaultFormatter": "golang.go",
66
"editor.formatOnSave": true,
77
"files.eol": "\n"
8+
},
9+
"[typescript][typescriptreact][javascript][javascriptreact][json][jsonc][yaml][github-actions-workflow]": {
10+
"editor.defaultFormatter": "dprint.dprint",
11+
"editor.formatOnSave": true
812
}
913
}

0 commit comments

Comments
 (0)