Skip to content

Commit d9b5839

Browse files
authored
feat: trunkio meta-linter (EddieHubCommunity#71)
* Init Trunk Check * add format command * Disable Telemetry * enable PR annotations * Fix lint comments * Run linter with dependencies installed * Fix invalid yaml * Update lint.yml * Update lint.yml (EddieHubCommunity#2) * Fix linter errors * Fix more linter errors * Add ignore for markdownlint on Changelog.md * Remove duplicate top level yaml in trunk config * Update Dockerfile
1 parent 4178792 commit d9b5839

13 files changed

+812
-1288
lines changed

.github/workflows/deploy.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Deploy to Caprover
2-
2+
permissions: read-all
33
on:
44
registry_package:
55
types: [published]

.github/workflows/docker.yml

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: Publish Docker
2+
permissions: read-all
23
on:
34
release:
45
types: [published]

.github/workflows/lint.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,7 @@ jobs:
1414
node-version: 22.4
1515
- name: Install dependencies
1616
run: npm ci
17-
- name: Run linter
18-
run: npm run lint
17+
- name: Trunk Check
18+
uses: trunk-io/trunk-action@v1
19+
# with:
20+
# post-annotations: true # only for fork PRs

.trunk/.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*out
2+
*logs
3+
*actions
4+
*notifications
5+
*tools
6+
plugins
7+
user_trunk.yaml
8+
user.yaml
9+
tmp

.trunk/configs/.hadolint.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Following source doesn't work in most setups
2+
ignored:
3+
- SC1090
4+
- SC1091

.trunk/configs/.markdownlint.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Prettier friendly markdownlint config (all formatting rules disabled)
2+
extends: markdownlint/style/prettier
3+
4+
# Disable MD024 rule
5+
MD024: false

.trunk/configs/.yamllint.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
rules:
2+
quoted-strings:
3+
required: only-when-needed
4+
extra-allowed: ["{|}"]
5+
key-duplicates: {}
6+
octal-values:
7+
forbid-implicit-octal: true

.trunk/configs/svgo.config.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
plugins: [
3+
{
4+
name: "preset-default",
5+
params: {
6+
overrides: {
7+
removeViewBox: false, // https://github.com/svg/svgo/issues/1128
8+
sortAttrs: true,
9+
removeOffCanvasPaths: true,
10+
},
11+
},
12+
},
13+
],
14+
};

.trunk/trunk.yaml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# This file controls the behavior of Trunk: https://docs.trunk.io/cli
2+
# To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml
3+
version: 0.1
4+
cli:
5+
version: 1.22.2
6+
# Trunk provides extensibility via plugins. (https://docs.trunk.io/plugins)
7+
plugins:
8+
sources:
9+
- id: trunk
10+
ref: v1.6.1
11+
uri: https://github.com/trunk-io/plugins
12+
# Many linters and tools depend on runtimes - configure them here. (https://docs.trunk.io/runtimes)
13+
runtimes:
14+
enabled:
15+
16+
17+
# This is the section where you manage your linters. (https://docs.trunk.io/check/configuration)
18+
lint:
19+
enabled:
20+
# Prisma
21+
22+
23+
# Security + IaS config
24+
25+
26+
27+
28+
# These scan dependencies, but require network access. Enable if it fits your project.
29+
30+
31+
32+
# Toml, Yaml, Markdown, etc.
33+
34+
35+
36+
37+
# Formatters and linters
38+
39+
- git-diff-check
40+
41+
42+
# Optimize SVGs and PNGs
43+
44+
- [email protected] # Manually added in case you add PNGs later
45+
ignore:
46+
- linters: [markdownlint]
47+
paths:
48+
- CHANGELOG.md
49+
actions:
50+
# Optional githooks that help you run check and format before push.
51+
enabled:
52+
- trunk-announce
53+
- trunk-check-pre-push
54+
- trunk-upgrade-available

Dockerfile

+17-4
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,28 @@ RUN npm ci --omit=dev --ignore-scripts
88

99
COPY . .
1010

11-
RUN npx prisma generate
12-
RUN npm run build
11+
RUN npx prisma generate && \
12+
npm run build
1313

1414
# Production image
1515
FROM node:${NODE_VERSION} AS production
1616
WORKDIR /usr/src/app
1717

18-
COPY --from=builder /usr/src/app .
18+
COPY --from=builder /usr/src/app /usr/src/app
1919

20-
EXPOSE 3000
20+
# Create a non-root user and group
21+
RUN groupadd -r appuser && useradd -r -g appuser -d /usr/src/app -s /sbin/nologin appuser
22+
23+
# Copy application files from builder
24+
COPY --from=builder /usr/src/app /usr/src/app
25+
26+
# Change ownership of the application directory
27+
RUN chown -R appuser:appuser /usr/src/app
28+
29+
# Switch to the non-root user
30+
USER appuser
31+
32+
# Added healthcheck to satisfy checkov lint, you should configure this according to your application
33+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 CMD curl -f http://localhost:3000/health || exit 1
2134

2235
CMD ["npm", "run", "start"]

compose.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ services:
2929
networks:
3030
- healthcheck
3131
healthcheck:
32-
test: ["CMD", "pg_isready", "-U", "user", "-d", "healthcheck"]
32+
test: [CMD, pg_isready, -U, user, -d, healthcheck]
3333
interval: 10s
3434
timeout: 5s
3535
retries: 5

0 commit comments

Comments
 (0)