+1
-1
.github/workflows/aqua.yml
+1
-1
.github/workflows/aqua.yml
-124
.github/workflows/services.yml
-124
.github/workflows/services.yml
···
1
-
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2
-
3
-
name: Build and Push Services
4
-
5
-
on:
6
-
push:
7
-
branches: [main]
8
-
paths:
9
-
- "services/**"
10
-
- "Cargo.toml"
11
-
- "Cargo.lock"
12
-
- ".github/workflows/services.yml"
13
-
pull_request:
14
-
branches: [main]
15
-
paths:
16
-
- "services/**"
17
-
- "Cargo.toml"
18
-
- "Cargo.lock"
19
-
- ".github/workflows/services.yml"
20
-
21
-
env:
22
-
REGISTRY: ghcr.io
23
-
CARGO_TERM_COLOR: always
24
-
SQLX_OFFLINE: true
25
-
26
-
jobs:
27
-
detect-services:
28
-
name: Detect Services to Build
29
-
runs-on: ubuntu-latest
30
-
outputs:
31
-
services: ${{ steps.detect.outputs.services }}
32
-
steps:
33
-
- name: Checkout repository
34
-
uses: actions/checkout@v4
35
-
36
-
- name: Detect services with Dockerfiles
37
-
id: detect
38
-
run: |
39
-
services=()
40
-
for service_dir in services/*/; do
41
-
service_name=$(basename "$service_dir")
42
-
# Skip special directories
43
-
if [[ "$service_name" == "target" || "$service_name" == "migrations" || "$service_name" == "types" || "$service_name" == ".sqlx" ]]; then
44
-
continue
45
-
fi
46
-
# Check if service has a Dockerfile
47
-
if [[ -f "$service_dir/Dockerfile" ]]; then
48
-
services+=("$service_name")
49
-
fi
50
-
done
51
-
52
-
# Convert to JSON array
53
-
services_json=$(printf '%s\n' "${services[@]}" | jq -R . | jq -s .)
54
-
echo "services=$services_json" >> $GITHUB_OUTPUT
55
-
echo "Detected services: $services_json"
56
-
57
-
build-service:
58
-
name: Build ${{ matrix.service }}
59
-
runs-on: ubuntu-latest
60
-
needs: detect-services
61
-
if: needs.detect-services.outputs.services != '[]'
62
-
strategy:
63
-
matrix:
64
-
service: ${{ fromJson(needs.detect-services.outputs.services) }}
65
-
permissions:
66
-
contents: read
67
-
packages: write
68
-
steps:
69
-
- name: Checkout repository
70
-
uses: actions/checkout@v4
71
-
72
-
- name: Log in to Container Registry
73
-
if: github.event_name != 'pull_request'
74
-
uses: docker/login-action@v3
75
-
with:
76
-
registry: ${{ env.REGISTRY }}
77
-
username: ${{ github.actor }}
78
-
password: ${{ secrets.GITHUB_TOKEN }}
79
-
80
-
- name: Extract metadata
81
-
id: meta
82
-
uses: docker/metadata-action@v5
83
-
with:
84
-
images: ${{ env.REGISTRY }}/${{ github.repository }}/${{ matrix.service }}
85
-
tags: |
86
-
type=ref,event=branch
87
-
type=ref,event=pr
88
-
type=sha,prefix=sha-
89
-
type=raw,value=latest,enable={{is_default_branch}}
90
-
91
-
- name: Set up Docker Buildx
92
-
uses: docker/setup-buildx-action@v3
93
-
94
-
- name: Build and push Docker image
95
-
uses: docker/build-push-action@v5
96
-
with:
97
-
context: ./services/${{ matrix.service }}
98
-
file: ./services/${{ matrix.service }}/Dockerfile
99
-
push: ${{ github.event_name != 'pull_request' }}
100
-
tags: ${{ steps.meta.outputs.tags }}
101
-
labels: ${{ steps.meta.outputs.labels }}
102
-
platforms: linux/amd64,linux/arm64
103
-
cache-from: type=gha,scope=${{ matrix.service }}
104
-
cache-to: type=gha,mode=max,scope=${{ matrix.service }}
105
-
106
-
test-services:
107
-
name: Test Services
108
-
runs-on: ubuntu-latest
109
-
steps:
110
-
- name: Checkout repository
111
-
uses: actions/checkout@v4
112
-
113
-
- name: Install Rust toolchain
114
-
uses: dtolnay/rust-toolchain@stable
115
-
116
-
- name: Cache Rust dependencies
117
-
uses: Swatinem/rust-cache@v2
118
-
with:
119
-
workspaces: services
120
-
121
-
- name: Run service tests
122
-
run: |
123
-
cd services
124
-
cargo test --all-features --workspace
+25
-1
packages/lexicons/lex-gen.sh
+25
-1
packages/lexicons/lex-gen.sh
···
1
-
lex gen-server ./src ./../../lexicons/**/*.* --yes
1
+
#!/bin/bash
2
+
set -e
3
+
4
+
# Navigate to the lexicons directory and find all .json files
5
+
cd ../../lexicons
6
+
json_files=$(find . -name "*.json" -type f)
7
+
8
+
# Go back to the lexicons package directory
9
+
cd ../packages/lexicons
10
+
11
+
# Check if we found any lexicon files
12
+
if [ -z "$json_files" ]; then
13
+
echo "No lexicon files found in ../../lexicons/"
14
+
exit 1
15
+
fi
16
+
17
+
# Convert the file list to absolute paths
18
+
lexicon_paths=""
19
+
for file in $json_files; do
20
+
lexicon_paths="$lexicon_paths ../../lexicons/$file"
21
+
done
22
+
23
+
# Generate lexicons
24
+
echo "Generating lexicons from: $lexicon_paths"
25
+
lex gen-server ./src $lexicon_paths --yes
+1
-1
packages/lexicons/package.json
+1
-1
packages/lexicons/package.json
+17
services/cadet/target.sh
+17
services/cadet/target.sh
···
1
+
#!/bin/bash
2
+
# Taken from https://github.com/DataDog/sdlc-gitops-sample-stack/blob/main/apps/pass-image-api/scripts/target.sh
3
+
set -e
4
+
5
+
# Map TARGETPLATFORM to Rust target
6
+
case "$TARGETPLATFORM" in
7
+
"linux/amd64")
8
+
export RUST_TARGET="x86_64-unknown-linux-gnu"
9
+
;;
10
+
"linux/arm64")
11
+
export RUST_TARGET="aarch64-unknown-linux-gnu"
12
+
;;
13
+
*)
14
+
echo "Unsupported platform: $TARGETPLATFORM"
15
+
exit 1
16
+
;;
17
+
esac