Skip to content

Commit ed1c5a6

Browse files
committed
chore: ci
1 parent 0360895 commit ed1c5a6

File tree

12 files changed

+298
-125
lines changed

12 files changed

+298
-125
lines changed

.devcontainer/Dockerfile

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
FROM docker.io/debian:bookworm-slim
2+
3+
# Versions
4+
ARG BUN_VERSION=1.3.8
5+
ARG DOTNET_VERSION=9.0
6+
ARG JUST_VERSION=1.46.0
7+
8+
# Create non-root user
9+
ARG USERNAME=dev
10+
ARG USER_UID=1000
11+
ARG USER_GID=$USER_UID
12+
13+
RUN groupadd --gid $USER_GID $USERNAME \
14+
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
15+
&& apt-get update \
16+
&& apt-get install -y --no-install-recommends sudo \
17+
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
18+
&& chmod 0440 /etc/sudoers.d/$USERNAME
19+
20+
# Install base dependencies
21+
RUN apt-get update && apt-get install -y --no-install-recommends \
22+
ca-certificates \
23+
curl \
24+
wget \
25+
git \
26+
&& rm -rf /var/lib/apt/lists/*
27+
28+
# Install .NET SDK
29+
RUN wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh \
30+
&& chmod +x dotnet-install.sh \
31+
&& ./dotnet-install.sh --channel ${DOTNET_VERSION} --install-dir /usr/share/dotnet \
32+
&& ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet \
33+
&& rm dotnet-install.sh
34+
35+
ENV DOTNET_ROOT=/usr/share/dotnet
36+
ENV DOTNET_CLI_TELEMETRY_OPTOUT=1
37+
ENV DOTNET_NOLOGO=1
38+
39+
# Install Bun globally
40+
ENV BUN_INSTALL=/usr/local
41+
RUN curl -fsSL https://bun.sh/install | bash -s "bun-v${BUN_VERSION}"
42+
43+
# Install Just
44+
RUN curl -fsSL https://just.systems/install.sh | bash -s -- --to /usr/local/bin --tag ${JUST_VERSION}
45+
46+
# Install Lefthook
47+
RUN curl -fsSL https://raw.githubusercontent.com/evilmartians/lefthook/master/install.sh | bash -s -- -d -b /usr/local/bin
48+
49+
WORKDIR /workspace
50+
51+
USER $USERNAME

.devcontainer/devcontainer.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/devcontainers/spec/main/schemas/devContainer.schema.json",
3+
"name": "Ladesa Messages",
4+
"build": {
5+
"dockerfile": "Dockerfile"
6+
},
7+
"features": {
8+
"ghcr.io/devcontainers/features/git:1": {},
9+
"ghcr.io/devcontainers/features/github-cli:1": {}
10+
},
11+
"postCreateCommand": "bun install && lefthook install",
12+
"customizations": {
13+
"vscode": {
14+
"settings": {
15+
"editor.formatOnSave": true,
16+
"editor.defaultFormatter": "biomejs.biome",
17+
"[typescript]": {
18+
"editor.defaultFormatter": "biomejs.biome"
19+
},
20+
"[json]": {
21+
"editor.defaultFormatter": "biomejs.biome"
22+
},
23+
"[csharp]": {
24+
"editor.defaultFormatter": "ms-dotnettools.csharp"
25+
}
26+
},
27+
"extensions": [
28+
"biomejs.biome",
29+
"ms-dotnettools.csharp",
30+
"ms-dotnettools.csdevkit",
31+
"oven.bun-vscode",
32+
"skellock.just",
33+
"typespec.typespec-vscode"
34+
]
35+
}
36+
},
37+
"remoteUser": "dev",
38+
"containerUser": "dev"
39+
}

.github/workflows/changesets.yml

Lines changed: 50 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,22 @@ on:
99
concurrency: ${{ github.workflow }}-${{ github.ref }}
1010

1111
jobs:
12+
lint:
13+
name: "[CI] Lint"
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout repo
18+
uses: actions/checkout@v6
19+
20+
- name: Run lint in devcontainer
21+
uses: devcontainers/ci@v0.3
22+
with:
23+
runCmd: bun install && bun run lint
24+
1225
changesets:
1326
name: "[CI] Changesets"
14-
27+
needs: lint
1528
runs-on: ubuntu-latest
1629

1730
permissions:
@@ -33,7 +46,7 @@ jobs:
3346
with:
3447
bun-version: "1.3.8"
3548

36-
- name: Install dependencies with bun
49+
- name: Install dependencies
3750
run: bun install
3851

3952
- name: Create Release Pull Request
@@ -47,22 +60,20 @@ jobs:
4760

4861
build-timetable-generator-v1:
4962
name: "[Build] timetable-generator-v1"
50-
51-
needs:
52-
- changesets
63+
needs: changesets
5364
if: needs.changesets.outputs.hasChangesets == 'false'
54-
5565
runs-on: ubuntu-latest
5666

5767
steps:
5868
- name: Checkout repo
5969
uses: actions/checkout@v6
6070

61-
- name: Install just
62-
uses: extractions/setup-just@v3
63-
64-
- name: Build all integrations
65-
run: just apis/timetable-generator-v1/build
71+
- name: Build in devcontainer
72+
uses: devcontainers/ci@v0.3
73+
with:
74+
runCmd: |
75+
bun install
76+
just apis/timetable-generator-v1/build
6677
6778
- name: Upload TypeScript artifact
6879
uses: actions/upload-artifact@v4
@@ -78,72 +89,58 @@ jobs:
7889

7990
publish-timetable-generator-v1-nuget:
8091
name: "[Publish] timetable-generator-v1 - NuGet"
81-
82-
needs:
83-
- build-timetable-generator-v1
84-
92+
needs: build-timetable-generator-v1
8593
runs-on: ubuntu-latest
8694

8795
environment:
8896
name: ci-timetable-generator-v1-dotnet
8997

90-
defaults:
91-
run:
92-
working-directory: dotnet/Ladesa.Messages.TimetableGenerator.V1
93-
9498
steps:
99+
- name: Checkout repo
100+
uses: actions/checkout@v6
101+
95102
- name: Download artifact
96103
uses: actions/download-artifact@v4
97104
with:
98105
name: timetable-generator-v1-dotnet
99-
path: dotnet
106+
path: apis/timetable-generator-v1/integrations/dotnet
100107

101-
- name: Setup .NET
102-
uses: actions/setup-dotnet@v4
108+
- name: Publish to NuGet in devcontainer
109+
uses: devcontainers/ci@v0.3
110+
env:
111+
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
103112
with:
104-
dotnet-version: "9.0.x"
105-
106-
- name: Restore dependencies
107-
run: dotnet restore
108-
109-
- name: Build
110-
run: dotnet build --configuration Release --no-restore
111-
112-
- name: Pack
113-
run: dotnet pack --configuration Release --no-build --output ./nupkg
114-
115-
- name: Push to NuGet
116-
run: dotnet nuget push ./nupkg/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
113+
runCmd: |
114+
cd apis/timetable-generator-v1/integrations/dotnet/Ladesa.Messages.TimetableGenerator.V1
115+
dotnet restore
116+
dotnet build --configuration Release --no-restore
117+
dotnet pack --configuration Release --no-build --output ./nupkg
118+
dotnet nuget push ./nupkg/*.nupkg --api-key "$NUGET_API_KEY" --source https://api.nuget.org/v3/index.json --skip-duplicate
117119
118120
publish-timetable-generator-v1-npm:
119121
name: "[Publish] timetable-generator-v1 - npm"
120-
121-
needs:
122-
- build-timetable-generator-v1
123-
122+
needs: build-timetable-generator-v1
124123
runs-on: ubuntu-latest
125124

126125
environment:
127126
name: ci-timetable-generator-v1-npm
128127

129-
defaults:
130-
run:
131-
working-directory: typescript
132-
133128
steps:
129+
- name: Checkout repo
130+
uses: actions/checkout@v6
131+
134132
- name: Download artifact
135133
uses: actions/download-artifact@v4
136134
with:
137135
name: timetable-generator-v1-typescript
138-
path: typescript
136+
path: apis/timetable-generator-v1/integrations/typescript
139137

140-
- name: Setup Node.js
141-
uses: actions/setup-node@v4
142-
with:
143-
node-version: "24"
144-
registry-url: "https://registry.npmjs.org"
138+
- name: Setup npmrc
139+
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > apis/timetable-generator-v1/integrations/typescript/.npmrc
145140

146-
- name: Publish to npm
147-
run: npm publish --access public
148-
env:
149-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
141+
- name: Publish to npm in devcontainer
142+
uses: devcontainers/ci@v0.3
143+
with:
144+
runCmd: |
145+
cd apis/timetable-generator-v1/integrations/typescript
146+
npm publish --access public

apis/timetable-generator-v1/integrations/dotnet/.docker/.containerignore

Lines changed: 0 additions & 21 deletions
This file was deleted.

apis/timetable-generator-v1/integrations/dotnet/.docker/Containerfile

Lines changed: 0 additions & 10 deletions
This file was deleted.

apis/timetable-generator-v1/json-schema/Containerfile

Lines changed: 0 additions & 10 deletions
This file was deleted.

apis/timetable-generator-v1/json-schema/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"private": true,
33
"dependencies": {
44
"@typespec/compiler": "^1.8.0",
5-
"@typespec/json-schema": "^1.8.0"
5+
"@typespec/json-schema": "^1.8.0",
6+
"quicktype": "^23.2.6"
67
},
78
"scripts": {
89
"build": "tsp compile --config=tspconfig.yaml src/main.tsp",

apis/timetable-generator-v1/justfile

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ ts_dir := project_root / "integrations" / "typescript"
77
ts_pkg_dir := ts_dir
88
cs_dir := project_root / "integrations" / "dotnet"
99
cs_project_dir := cs_dir / "Ladesa.Messages.TimetableGenerator.V1"
10-
bun_image := "docker.io/oven/bun:1.3.8"
1110

1211
# Lista comandos disponíveis
1312
default:
@@ -18,47 +17,41 @@ build: build-schema build-integrations
1817

1918
# Gera JSON Schema via TypeSpec
2019
build-schema:
21-
podman build -t ladesa.local/typespec-builder "{{ schema_dir }}"
22-
mkdir -p "{{ schema_dist }}"
23-
podman run --rm \
24-
-v "{{ schema_dist }}":/build/lib/json-schema \
25-
ladesa.local/typespec-builder
20+
cd "{{ schema_dir }}" && bun install --frozen-lockfile && bun run build
2621

2722
# Build apenas integrações (ts e cs em paralelo)
2823
build-integrations: build-integration-ts build-integration-cs
2924

3025
# Gera TypeScript via quicktype
3126
build-integration-ts:
3227
mkdir -p "{{ ts_pkg_dir }}/lib"
33-
podman run --rm \
34-
-v "{{ schema_dist }}":/input:ro \
35-
-v "{{ ts_pkg_dir }}/lib":/output \
36-
{{ bun_image }} \
37-
bun x quicktype@23.2.6 \
38-
--src-lang schema \
39-
'/input/schema.json#/$defs/' \
40-
-o /output/out.ts
28+
cd "{{ schema_dir }}" && bunx quicktype \
29+
--src-lang schema \
30+
'{{ schema_dist }}/schema.json#/$defs/' \
31+
-o "{{ ts_pkg_dir }}/lib/out.ts"
4132

4233
# Gera C# via quicktype
4334
build-integration-cs:
4435
mkdir -p "{{ cs_project_dir }}/Generated"
45-
podman run --rm \
46-
-v "{{ schema_dist }}":/input:ro \
47-
-v "{{ cs_project_dir }}/Generated":/output \
48-
{{ bun_image }} \
49-
bun x quicktype@23.2.6 \
50-
--src-lang schema \
51-
'/input/schema.json#/$defs/' \
52-
-o /output/Messages.cs \
53-
--namespace Ladesa.Messages.TimetableGenerator.V1 \
54-
--framework SystemTextJson
36+
cd "{{ schema_dir }}" && bunx quicktype \
37+
--src-lang schema \
38+
'{{ schema_dist }}/schema.json#/$defs/' \
39+
-o "{{ cs_project_dir }}/Generated/Messages.cs" \
40+
--namespace Ladesa.Messages.TimetableGenerator.V1 \
41+
--framework SystemTextJson
42+
43+
# Build .NET project
44+
build-dotnet:
45+
cd "{{ cs_project_dir }}" && dotnet build
5546

5647
# Limpa artefatos gerados
5748
clean:
5849
rm -rf "{{ schema_dist }}"
5950
rm -rf "{{ ts_pkg_dir }}/lib"
6051
rm -rf "{{ cs_project_dir }}/Generated"
52+
rm -rf "{{ cs_project_dir }}/bin"
53+
rm -rf "{{ cs_project_dir }}/obj"
6154

62-
# Limpa imagens de container
63-
clean-images:
64-
-podman rmi ladesa.local/typespec-builder
55+
# Watch mode para desenvolvimento
56+
watch:
57+
cd "{{ schema_dir }}" && bun run --watch build

0 commit comments

Comments
 (0)