Skip to content

Commit d458abb

Browse files
committed
feat: updated CI/CD
1 parent 4447b33 commit d458abb

7 files changed

Lines changed: 574 additions & 5 deletions

File tree

.github/workflows/ci.yml

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,14 @@ permissions:
1010
contents: read
1111

1212
jobs:
13-
lint-and-test:
14-
name: Lint & Format Check
13+
security-checks:
14+
name: Security Checks
15+
uses: ./.github/workflows/reusable/security-checks.yml
16+
with:
17+
fail-on-error: false
18+
19+
lint-and-format:
20+
name: Lint & Format
1521
runs-on: ubuntu-latest
1622
steps:
1723
- name: Checkout code
@@ -32,6 +38,64 @@ jobs:
3238
- name: Check Prettier formatting
3339
run: npm run format:check
3440

41+
backend-tests:
42+
name: Backend Tests
43+
runs-on: ubuntu-latest
44+
steps:
45+
- name: Checkout code
46+
uses: actions/checkout@v5
47+
48+
- name: Setup Node.js
49+
uses: actions/setup-node@v5
50+
with:
51+
node-version: '22'
52+
cache: 'npm'
53+
54+
- name: Install backend dependencies
55+
run: npm run cinstall:backend
56+
57+
- name: Run backend tests
58+
run: npm run test:run
59+
60+
frontend-tests:
61+
name: Frontend Tests
62+
runs-on: ubuntu-latest
63+
steps:
64+
- name: Checkout code
65+
uses: actions/checkout@v5
66+
67+
- name: Setup Node.js
68+
uses: actions/setup-node@v5
69+
with:
70+
node-version: '22'
71+
cache: 'npm'
72+
73+
- name: Install frontend dependencies
74+
run: npm run cinstall:frontend
75+
76+
- name: Run frontend tests
77+
run: npm run test:frontend
78+
79+
build-frontend:
80+
name: Build Frontend
81+
uses: ./.github/workflows/reusable/build-frontend.yml
82+
83+
verify-scripts:
84+
name: Verify Scripts
85+
runs-on: ubuntu-latest
86+
steps:
87+
- name: Checkout code
88+
uses: actions/checkout@v5
89+
90+
- name: Setup Node.js
91+
uses: actions/setup-node@v5
92+
with:
93+
node-version: '22'
94+
cache: 'npm'
95+
96+
- name: Install dependencies
97+
run: npm run cinstall:backend
98+
3599
- name: Verify scripts exist
36100
run: |
37101
echo "Checking sync-versions script..."

.github/workflows/dev-build.yml

Lines changed: 272 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,272 @@
1+
name: Development Build
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
check-trigger:
13+
name: Check if triggered by Release Please
14+
runs-on: ubuntu-latest
15+
outputs:
16+
should_build: ${{ steps.check.outputs.should_build }}
17+
dev_version: ${{ steps.version.outputs.dev_version }}
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v5
21+
with:
22+
fetch-depth: 2
23+
24+
- name: Check if triggered by Release Please
25+
id: check
26+
run: |
27+
# Get the commit message and author
28+
COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s")
29+
COMMIT_AUTHOR=$(git log -1 --pretty=format:"%an")
30+
31+
echo "Commit message: $COMMIT_MESSAGE"
32+
echo "Commit author: $COMMIT_AUTHOR"
33+
34+
# Skip if this is a release-please commit
35+
if [[ "$COMMIT_MESSAGE" =~ ^chore\(main\): ]] || [[ "$COMMIT_AUTHOR" == "github-actions[bot]" ]]; then
36+
echo "Skipping development build - triggered by Release Please"
37+
echo "should_build=false" >> $GITHUB_OUTPUT
38+
else
39+
echo "Proceeding with development build"
40+
echo "should_build=true" >> $GITHUB_OUTPUT
41+
fi
42+
43+
- name: Calculate development version
44+
id: version
45+
if: steps.check.outputs.should_build == 'true'
46+
run: |
47+
# Get current version from package.json
48+
CURRENT_VERSION=$(node -p "require('./package.json').version")
49+
50+
# Split version into parts
51+
IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION"
52+
MAJOR=${VERSION_PARTS[0]}
53+
MINOR=${VERSION_PARTS[1]}
54+
PATCH=${VERSION_PARTS[2]}
55+
56+
# Increment patch version for development
57+
NEW_PATCH=$((PATCH + 1))
58+
DEV_VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}-dev"
59+
60+
echo "Current version: $CURRENT_VERSION"
61+
echo "Development version: $DEV_VERSION"
62+
echo "dev_version=$DEV_VERSION" >> $GITHUB_OUTPUT
63+
64+
security-pre-check:
65+
name: Security Pre-Check
66+
needs: check-trigger
67+
if: needs.check-trigger.outputs.should_build == 'true'
68+
uses: ./.github/workflows/reusable/security-checks.yml
69+
with:
70+
fail-on-error: true
71+
72+
build-development-packages:
73+
name: Build Development Packages
74+
needs: [check-trigger, security-pre-check]
75+
if: needs.check-trigger.outputs.should_build == 'true'
76+
runs-on: self-hosted
77+
env:
78+
VERSION: ${{ needs.check-trigger.outputs.dev_version }}
79+
PACKAGE_NAME: armor-dev
80+
ARCH: amd64
81+
steps:
82+
# Debian Build Steps
83+
- name: Checkout for Debian build
84+
uses: actions/checkout@v5
85+
86+
- name: Setup Node.js
87+
uses: actions/setup-node@v4
88+
with:
89+
node-version: '22'
90+
cache: 'npm'
91+
92+
- name: Install dependencies
93+
run: npm run cinstall:all:nodev
94+
95+
- name: Build frontend
96+
run: npm run build
97+
98+
- name: Create Debian package structure
99+
run: |
100+
mkdir -p "${PACKAGE_NAME}_${VERSION}_${ARCH}"/{opt/armor/web,opt/armor,etc/systemd/system,var/lib/armor,var/log/armor,usr/share/man/man8,usr/share/man/man5,DEBIAN}
101+
102+
- name: Copy application files to Debian package
103+
run: |
104+
cp -r models routes middleware config utils services packaging app.js package.json "${PACKAGE_NAME}_${VERSION}_${ARCH}/opt/armor/"
105+
cp -r node_modules "${PACKAGE_NAME}_${VERSION}_${ARCH}/opt/armor/"
106+
cp -r web/dist "${PACKAGE_NAME}_${VERSION}_${ARCH}/opt/armor/web/dist"
107+
# Keep public assets for Swagger theming
108+
cp -r web/public "${PACKAGE_NAME}_${VERSION}_${ARCH}/opt/armor/web/public"
109+
110+
- name: Copy configuration files to Debian package
111+
run: |
112+
cp packaging/DEBIAN/systemd/armor.service "${PACKAGE_NAME}_${VERSION}_${ARCH}/etc/systemd/system/"
113+
cp packaging/DEBIAN/postinst packaging/DEBIAN/prerm packaging/DEBIAN/postrm "${PACKAGE_NAME}_${VERSION}_${ARCH}/DEBIAN/"
114+
115+
- name: Install man pages
116+
run: |
117+
# Copy and compress man pages following Debian Policy
118+
gzip -9 -c packaging/DEBIAN/man/armor.8 > "${PACKAGE_NAME}_${VERSION}_${ARCH}/usr/share/man/man8/armor.8.gz"
119+
gzip -9 -c packaging/DEBIAN/man/armor.yaml.5 > "${PACKAGE_NAME}_${VERSION}_${ARCH}/usr/share/man/man5/armor.yaml.5.gz"
120+
121+
- name: Create Debian control file
122+
run: |
123+
cat > "${PACKAGE_NAME}_${VERSION}_${ARCH}/DEBIAN/control" << EOF
124+
Package: armor-dev
125+
Version: ${VERSION}
126+
Section: misc
127+
Priority: optional
128+
Architecture: ${ARCH}
129+
Maintainer: MarkProminic <MarkProminic@users.noreply.github.com>
130+
Depends: nodejs (>= 22.0.0), sqlite3, openssl
131+
Conflicts: armor
132+
Description: Armor (Development) - Armor Reliably Manages Online Resources
133+
A secure Node.js file server that provides directory listings with SHA256 checksums and authenticated file upload capabilities over HTTPS.
134+
This is a development version.
135+
Homepage: https://github.com/STARTcloud/armor_private
136+
EOF
137+
138+
- name: Set Debian package permissions
139+
run: |
140+
find "${PACKAGE_NAME}_${VERSION}_${ARCH}" -type d -exec chmod 755 {} \;
141+
find "${PACKAGE_NAME}_${VERSION}_${ARCH}" -type f -exec chmod 644 {} \;
142+
chmod 755 "${PACKAGE_NAME}_${VERSION}_${ARCH}/DEBIAN"/{postinst,prerm,postrm}
143+
144+
- name: Build Debian package
145+
run: |
146+
dpkg-deb --build "${PACKAGE_NAME}_${VERSION}_${ARCH}" "${PACKAGE_NAME}_${VERSION}_${ARCH}.deb"
147+
148+
# OmniOS Build Steps
149+
- name: Fresh checkout for OmniOS build
150+
uses: actions/checkout@v5
151+
with:
152+
path: omnios-source
153+
clean: true
154+
155+
- name: Clean OmniOS build directory
156+
run: |
157+
ssh ghrunner@omnios.packages.startcloud.com "rm -rf /local/builds/armor-dev/* /local/builds/armor-dev/.*" || true
158+
159+
- name: Sync source code to OmniOS
160+
run: |
161+
rsync -av \
162+
--exclude='.git' \
163+
--exclude='node_modules' \
164+
--exclude='web/node_modules' \
165+
--exclude='web/dist' \
166+
--exclude='*.deb' \
167+
omnios-source/ ghrunner@omnios.packages.startcloud.com:/local/builds/armor-dev/
168+
169+
- name: Build package on OmniOS
170+
run: |
171+
ssh ghrunner@omnios.packages.startcloud.com "
172+
cd /local/builds/armor-dev &&
173+
export PATH=/opt/ooce/bin:/opt/ooce/node-22/bin:\$PATH &&
174+
export MAKE=gmake &&
175+
export DEV_VERSION=${VERSION} &&
176+
chmod +x packaging/omnios/build.sh &&
177+
./packaging/omnios/build.sh
178+
"
179+
180+
- name: Transfer OmniOS package back
181+
run: |
182+
rsync -av ghrunner@omnios.packages.startcloud.com:/local/builds/armor-dev/*.p5p ./ || echo "No .p5p files found"
183+
184+
- name: Upload Debian package to repository server
185+
run: |
186+
rsync -av ${PACKAGE_NAME}_*.deb startcloud@172.17.204.177:/tmp/
187+
188+
- name: Add package to repository pool
189+
run: |
190+
ssh startcloud@172.17.204.177 "
191+
mkdir -p /local/public/debian/pool/main/z/armor-dev
192+
cp /tmp/${PACKAGE_NAME}_*.deb /local/public/debian/pool/main/z/armor-dev/
193+
"
194+
195+
- name: Update repository Packages files for all suites
196+
run: |
197+
ssh startcloud@172.17.204.177 "
198+
cd /local/public/debian
199+
# Generate Packages files for each suite
200+
for suite in bookworm trixie; do
201+
dpkg-scanpackages --arch amd64 pool/ > dists/\$suite/main/binary-amd64/Packages
202+
gzip -c dists/\$suite/main/binary-amd64/Packages > dists/\$suite/main/binary-amd64/Packages.gz
203+
done
204+
"
205+
206+
- name: Generate Release files for all suites
207+
run: |
208+
ssh startcloud@172.17.204.177 "
209+
cd /local/public/debian
210+
# Generate Release files for each suite
211+
for suite in bookworm trixie; do
212+
cd dists/\$suite
213+
/local/generate-release.sh \$suite > Release
214+
cd ../..
215+
done
216+
"
217+
218+
- name: Create stable distribution with proper Release file
219+
run: |
220+
ssh startcloud@172.17.204.177 "
221+
cd /local/public/debian/dists
222+
rm -rf stable 2>/dev/null || true
223+
cp -r trixie stable
224+
cd stable
225+
/local/generate-release.sh stable > Release
226+
"
227+
228+
- name: Sign repository for all suites including stable
229+
run: |
230+
ssh startcloud@172.17.204.177 "
231+
cd /local/public/debian
232+
# Sign each suite including stable
233+
for suite in bookworm trixie stable; do
234+
cd dists/\$suite
235+
export GNUPGHOME=\$(mktemp -d /local/pgp/pgpkeys-XXXXXX)
236+
cat /local/pgp/pgp-key.private | gpg --import
237+
cat Release | gpg --default-key startcloud -abs > Release.gpg
238+
cat Release | gpg --default-key startcloud -abs --clearsign > InRelease
239+
rm -rf \$GNUPGHOME
240+
cd ../..
241+
done
242+
"
243+
244+
- name: Publish OmniOS package to repository
245+
run: |
246+
ssh ghrunner@omnios.packages.startcloud.com "
247+
cd /local/builds/armor-dev &&
248+
pfexec pkgsend publish -d proto -s file:///local/public/r151054/pkg armor.p5m.final &&
249+
pfexec pkgrepo refresh -s /local/public/r151054/pkg &&
250+
pfexec svcadm restart pkg/server:r151054_STARTcloud
251+
"
252+
253+
- name: Upload artifacts
254+
uses: actions/upload-artifact@v4
255+
with:
256+
name: 'development-packages'
257+
path: |
258+
*.deb
259+
*.p5p
260+
retention-days: 30
261+
262+
- name: Clean up
263+
run: |
264+
ssh ghrunner@omnios.packages.startcloud.com "rm -rf /local/builds/armor-dev/*"
265+
ssh startcloud@172.17.204.177 "rm -f /tmp/${PACKAGE_NAME}_*.deb"
266+
267+
- name: Summary
268+
run: |
269+
echo "Development packages built and published:"
270+
echo "- Version: ${VERSION}"
271+
echo "- Debian package: ${PACKAGE_NAME}_${VERSION}_${ARCH}.deb"
272+
echo "- Packages published to repositories"

.github/workflows/release-please.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,17 @@ jobs:
2828
uses: googleapis/release-please-action@v4
2929
id: release
3030

31-
build-packages:
31+
security-pre-check:
32+
name: Security Pre-Check
3233
needs: release-please
3334
if: ${{ needs.release-please.outputs.release_created }}
35+
uses: ./.github/workflows/reusable/security-checks.yml
36+
with:
37+
fail-on-error: true
38+
39+
build-packages:
40+
needs: [release-please, security-pre-check]
41+
if: ${{ needs.release-please.outputs.release_created }}
3442
runs-on: self-hosted
3543
steps:
3644
# Debian Build Steps

0 commit comments

Comments
 (0)