Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 113 additions & 24 deletions .github/workflows/api.yml → .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: api
name: CI/CD

on:
push:
Expand All @@ -10,34 +10,40 @@

permissions:
contents: read
id-token: write

concurrency:
group: ci-cd-${{ github.ref }}
cancel-in-progress: false

jobs:
test:
name: Integration Tests
runs-on: ubuntu-latest
integration-tests:
name: Run Integration Tests
runs-on: ubuntu-26.04
steps:
- name: Checkout
- name: Checkout Code
uses: actions/checkout@v7

- name: Set up Go
- name: Set Up Go
uses: actions/setup-go@v7
with:
go-version: stable
cache-dependency-path: |
api/go.sum
tests/go.sum

- name: Generate Firebase credentials
- name: Generate Firebase Credentials
run: |
bash tests/generate-firebase-credentials.sh tests/firebase-credentials.json
echo "FIREBASE_CREDENTIALS=$(jq -c . tests/firebase-credentials.json)" >> $GITHUB_ENV

- name: Generate adapter certificates
- name: Generate Adapter Certificates
run: bash tests/generate-adapter-certificates.sh tests/certs

- name: Start Services
working-directory: ./tests
run: docker compose up -d --build

- name: Wait for services to be healthy
- name: Wait for Healthy Services
working-directory: ./tests
run: |
echo "Waiting for MongoDB to be healthy..."
Expand Down Expand Up @@ -74,7 +80,7 @@
working-directory: ./tests
run: |
echo "Waiting for seed container to finish..."
docker compose wait seed || true
docker compose wait seed
sleep 2

- name: Run Handler Integration Tests
Expand All @@ -83,11 +89,11 @@
USER_API_KEY: test-user-api-key
run: go test -tags integration -v -timeout 60s ./pkg/handlers

- name: Run Integration Tests
- name: Run End-to-End Integration Tests
working-directory: ./tests
run: go test -v -timeout 300s ./...

- name: Collect Logs on Failure
- name: Collect Service Logs on Failure
if: failure()
working-directory: ./tests
run: |
Expand All @@ -98,28 +104,32 @@
working-directory: ./tests
run: docker compose down -v

deploy:
name: Deploy
runs-on: ubuntu-latest
needs: test
deploy-api:
name: Deploy API
runs-on: ubuntu-26.04
needs: integration-tests
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
timeout-minutes: 60
permissions:
contents: read
id-token: write
steps:
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v3
with:
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}

- name: Set up Cloud SDK
- name: Set Up Google Cloud SDK
uses: google-github-actions/setup-gcloud@v3

- name: Trigger Cloud Build Deploy
- name: Build and Deploy API
run: |
BUILD_ID=$(gcloud builds triggers run api-httpsms-com \
--region=global \
--project=httpsms-86c51 \
--sha=${{ github.sha }} \
--substitutions=_VERSION=${{ github.run_number }} \
--substitutions=_VERSION=${{ github.run_id }} \
--format="value(metadata.build.id)")
echo -e "Cloud Build: \033[34mhttps://console.cloud.google.com/cloud-build/builds/$BUILD_ID?project=httpsms-86c51\033[0m"
echo ""
Expand All @@ -135,12 +145,91 @@
sleep 30
done

build-web:
name: Build Web
needs: integration-tests
runs-on: ubuntu-26.04
defaults:
run:
working-directory: ./web
steps:
- name: Checkout Code
uses: actions/checkout@v7

- name: Set Up Node.js
uses: actions/setup-node@v7
with:
node-version: "24.18"

- name: Set Up pnpm
uses: pnpm/action-setup@v6

Check warning on line 165 in .github/workflows/ci.yaml

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

.github/workflows/ci.yaml#L165

An action sourced from a third-party repository on GitHub is not pinned to a full length commit SHA. Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release.
with:
version: 11.11.0

- name: Install Web Dependencies
run: pnpm install --trust-lockfile

- name: Lint Web
run: pnpm lint

- name: Run Web Tests
run: pnpm test

- name: Build Web
run: mv .env.production .env && pnpm run generate

- name: Upload Web Build
uses: actions/upload-artifact@v7
with:
name: web-build
path: web/.output/public
include-hidden-files: true
if-no-files-found: error
retention-days: 1

deploy-web:
name: Deploy Web
needs: deploy
name: Deploy Web (${{ matrix.provider }})
needs: [deploy-api, build-web]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-26.04
permissions:
contents: read
pull-requests: write
deployments: write
uses: ./.github/workflows/web.yml
secrets: inherit
strategy:
fail-fast: false
matrix:
provider: [Cloudflare, Firebase]
steps:
- name: Checkout Code
uses: actions/checkout@v7

- name: Set Up Node.js
uses: actions/setup-node@v7
with:
node-version: "24.18"

- name: Download Web Build
uses: actions/download-artifact@v8
with:
name: web-build
path: web/.output/public

- name: Deploy Web to Cloudflare
if: matrix.provider == 'Cloudflare'
uses: cloudflare/wrangler-action@v4

Check warning on line 220 in .github/workflows/ci.yaml

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

.github/workflows/ci.yaml#L220

An action sourced from a third-party repository on GitHub is not pinned to a full length commit SHA. Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release.
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy web/.output/public --project-name=httpsms
gitHubToken: ${{ secrets.GITHUB_TOKEN }}

- name: Deploy Web to Firebase
if: matrix.provider == 'Firebase'
uses: FirebaseExtended/action-hosting-deploy@500ac625ca2dd40cbd15f7659af953801858032a
with:
repoToken: "${{ secrets.GITHUB_TOKEN }}"
channelId: live
entryPoint: "./web"
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_HTTPSMS_86C51 }}"
projectId: httpsms-86c51
90 changes: 0 additions & 90 deletions .github/workflows/web.yml

This file was deleted.

3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# httpSMS

[![Web](https://github.com/NdoleStudio/httpsms/actions/workflows/web.yml/badge.svg)](https://github.com/NdoleStudio/httpsms/actions/workflows/web.yml)
[![API](https://github.com/NdoleStudio/httpsms/actions/workflows/api.yml/badge.svg)](https://github.com/NdoleStudio/httpsms/actions/workflows/api.yml)
[![CI/CD](https://github.com/NdoleStudio/httpsms/actions/workflows/ci.yaml/badge.svg)](https://github.com/NdoleStudio/httpsms/actions/workflows/ci.yaml)
[![GitHub contributors](https://img.shields.io/github/contributors/NdoleStudio/httpsms)](https://github.com/NdoleStudio/httpsms/graphs/contributors)
[![GitHub license](https://img.shields.io/github/license/NdoleStudio/httpsms?color=brightgreen)](https://github.com/NdoleStudio/httpsms/blob/master/LICENSE)
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md)
Expand Down
4 changes: 2 additions & 2 deletions api/cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
steps:
- name: "gcr.io/kaniko-project/executor:v1.23.2"
id: "Build image and push"
id: "Build and Push API Image"
dir: "api"
args:
- "--destination=us.gcr.io/$PROJECT_ID/$_SERVICE_NAME:$_VERSION"
Expand All @@ -10,7 +10,7 @@ steps:
- "--build-arg=VERSION=$_VERSION"
- "--snapshot-mode=time"

- id: "Deploy to cloud run"
- id: "Deploy API"
name: "gcr.io/cloud-builders/gcloud"
entrypoint: "bash"
args:
Expand Down
9 changes: 8 additions & 1 deletion tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,18 @@ cd tests && \

## CI/CD

`.github/workflows/api.yml` generates both the fake Firebase credential and
`.github/workflows/ci.yaml` generates both the fake Firebase credential and
the adapter CA/server certificate before building the Compose stack. The
workflow runs API handler integration tests and this complete host-side suite,
collects service logs on failure, and always tears the stack down.

After integration tests pass, the CI/CD workflow builds the web frontend and
deploys the API in parallel. On pushes to `main`, the web build is deployed to
Cloudflare and Firebase in parallel only after both jobs succeed. Pull requests
run integration tests and web validation/build without deploying. Both the API
and web use the GitHub Actions run ID as their version, preserving increasing
versions across workflow file renames.

## Test Data

| Entity | Value |
Expand Down
2 changes: 1 addition & 1 deletion web/firebase.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"hosting": {
"public": "dist",
"public": ".output/public",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"rewrites": [
{
Expand Down
2 changes: 1 addition & 1 deletion web/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export default defineNuxtConfig({
runtimeConfig: {
public: {
apiBaseUrl: process.env.API_BASE_URL || 'http://localhost:8000',
clientVersion: process.env.GITHUB_RUN_NUMBER || 'dev',
clientVersion: process.env.GITHUB_RUN_ID || 'dev',
appUrl: process.env.APP_URL || 'https://httpsms.com',
appName: process.env.APP_NAME || 'HTTP SMS',
appGithubUrl:
Expand Down
Loading