Skip to content

Commit e07599f

Browse files
authored
Merge branch 'main' into feat/tests
2 parents dfe2520 + e6d50d4 commit e07599f

7 files changed

Lines changed: 151 additions & 5 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
workflow_dispatch: {}
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}-ci
12+
cancel-in-progress: true
13+
14+
jobs:
15+
build:
16+
name: Build & Lint
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Setup pnpm
24+
uses: pnpm/action-setup@v2
25+
with:
26+
version: 10
27+
28+
- name: Setup Node.js
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: '22'
32+
cache: 'pnpm'
33+
34+
- name: Generate function packages
35+
run: node --experimental-strip-types scripts/generate.ts
36+
37+
- name: Install dependencies
38+
run: pnpm install --frozen-lockfile
39+
40+
- name: Build
41+
run: pnpm build
42+
43+
- name: Lint
44+
run: pnpm lint

.github/workflows/docker.yaml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Publish Docker Images
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
workflow_dispatch: {}
9+
10+
permissions:
11+
contents: read
12+
packages: write
13+
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.ref }}-docker
16+
cancel-in-progress: true
17+
18+
jobs:
19+
discover:
20+
name: Discover functions
21+
runs-on: ubuntu-latest
22+
outputs:
23+
matrix: ${{ steps.find.outputs.matrix }}
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
28+
- name: Find functions from handler.json
29+
id: find
30+
run: |
31+
entries=$(
32+
for f in functions/*/handler.json; do
33+
[ -f "$f" ] || continue
34+
name=$(jq -r .name "$f")
35+
dir=$(basename "$(dirname "$f")")
36+
echo "{\"name\":\"$name\",\"dir\":\"$dir\"}"
37+
done | jq -s -c '.'
38+
)
39+
echo "matrix={\"include\":$entries}" >> "$GITHUB_OUTPUT"
40+
echo "Discovered functions: $entries"
41+
42+
build:
43+
name: Build ${{ matrix.name }}-fn
44+
needs: discover
45+
runs-on: ubuntu-latest
46+
if: ${{ needs.discover.outputs.matrix != '{"include":[]}' }}
47+
48+
strategy:
49+
fail-fast: false
50+
matrix: ${{ fromJSON(needs.discover.outputs.matrix) }}
51+
52+
env:
53+
REGISTRY: ghcr.io
54+
55+
steps:
56+
- name: Checkout
57+
uses: actions/checkout@v4
58+
59+
- name: Setup Node.js
60+
uses: actions/setup-node@v4
61+
with:
62+
node-version: '22'
63+
64+
- name: Generate Dockerfile
65+
run: |
66+
node --experimental-strip-types scripts/generate.ts --only=${{ matrix.dir }}
67+
68+
- name: Set up Docker Buildx
69+
uses: docker/setup-buildx-action@v3
70+
71+
- name: Log in to GHCR
72+
if: github.event_name != 'pull_request'
73+
uses: docker/login-action@v3
74+
with:
75+
registry: ${{ env.REGISTRY }}
76+
username: ${{ github.actor }}
77+
password: ${{ secrets.GITHUB_TOKEN }}
78+
79+
- name: Docker meta
80+
id: meta
81+
uses: docker/metadata-action@v5
82+
with:
83+
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ matrix.name }}-fn
84+
tags: |
85+
type=ref,event=tag
86+
type=semver,pattern={{version}}
87+
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
88+
type=sha,format=short,prefix=
89+
90+
- name: Build and push
91+
uses: docker/build-push-action@v5
92+
with:
93+
context: .
94+
file: generated/${{ matrix.dir }}/Dockerfile
95+
push: ${{ github.event_name != 'pull_request' }}
96+
tags: ${{ steps.meta.outputs.tags }}
97+
cache-from: type=gha,scope=${{ matrix.name }}
98+
cache-to: type=gha,mode=max,scope=${{ matrix.name }}

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
.PHONY: build clean lint generate dev dev-build dev-down docker-build
1+
.PHONY: install build clean lint generate dev dev-build dev-down docker-build
2+
3+
install:
4+
node --experimental-strip-types scripts/generate.ts
5+
pnpm install
26

37
build:
48
pnpm run build

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
"scripts": {
1919
"generate": "node --experimental-strip-types scripts/generate.ts",
2020
"generate:all": "node --experimental-strip-types scripts/generate.ts",
21-
"preinstall": "node --experimental-strip-types scripts/generate.ts",
2221
"clean": "pnpm -r run clean",
2322
"build": "pnpm -r run build",
2423
"docker:build": "node --experimental-strip-types scripts/docker-build.ts --all",

templates/node-graphql/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ FROM node:22-alpine AS build
22
RUN npm install -g pnpm@10.12.2
33
WORKDIR /app
44
COPY . .
5-
RUN node --experimental-strip-types scripts/generate.ts --only={{name}} \
5+
RUN node --experimental-strip-types scripts/generate.ts \
66
&& pnpm install --frozen-lockfile \
77
&& pnpm --filter @constructive-io/{{name}}-fn... build
88

99
FROM node:22-alpine AS deploy
1010
RUN npm install -g pnpm@10.12.2
1111
COPY --from=build /app /app
1212
WORKDIR /app
13-
RUN pnpm --filter @constructive-io/{{name}}-fn deploy /deploy --prod
13+
RUN pnpm --filter @constructive-io/{{name}}-fn deploy --legacy /deploy --prod
1414

1515
FROM node:22-alpine
1616
WORKDIR /app

templates/node-graphql/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# @constructive-io/{{name}}-fn
1+
# {{name}}-fn
22

33
{{description}}

templates/node-graphql/tsconfig.esm.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"compilerOptions": {
44
"outDir": "dist/esm",
55
"module": "es2022",
6+
"rootDir": ".",
67
"declaration": false
78
}
89
}

0 commit comments

Comments
 (0)