GitHub actions

This commit is contained in:
Daniel Pupius
2025-05-02 12:22:45 -07:00
parent 92313be6cd
commit 6675c50e97
5 changed files with 195 additions and 29 deletions

75
.github/workflows/cicd.yml vendored Normal file
View File

@@ -0,0 +1,75 @@
name: CI/CD Pipeline
on:
push:
branches: [ "main" ]
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
GO_VERSION: '1.24'
NODE_VERSION: '20'
jobs:
test-go:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Install Protocol Buffers Compiler
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler
- name: Generate Protocol Buffers
run: make gen-proto
- name: Install Go dependencies
run: go mod download
- name: Run Go tests
run: make test
- name: Check Go formatting
run: make fmt-check
- name: Build binary
run: make build
test-web:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: 'web/pnpm-lock.yaml'
- name: Install pnpm
uses: pnpm/action-setup@v3
with:
version: latest
run_install: false
- name: Install web dependencies
working-directory: ./web
run: pnpm install
- name: Run web lint
run: make web-lint
- name: Run web tests
run: make web-test
- name: Build web assets
run: make web-build

97
.github/workflows/pr-validation.yml vendored Normal file
View File

@@ -0,0 +1,97 @@
name: PR Validation
on:
pull_request:
branches: [ "main" ]
workflow_dispatch:
env:
GO_VERSION: '1.24'
NODE_VERSION: '20'
jobs:
validate-go:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Install Protocol Buffers Compiler
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler
- name: Generate Protocol Buffers
run: make gen-proto
- name: Install Go dependencies
run: go mod download
- name: Run Go tests
run: make test
- name: Check go fmt
run: make fmt-check
- name: Build binary
run: make build
validate-web:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: 'web/pnpm-lock.yaml'
- name: Install pnpm
uses: pnpm/action-setup@v3
with:
version: latest
run_install: false
- name: Install web dependencies
working-directory: ./web
run: pnpm install
- name: Run ESLint
run: make web-lint
- name: Run web tests
run: make web-test
- name: Build web assets
run: make web-build
- name: Upload web test results
uses: actions/upload-artifact@v4
if: always()
with:
name: web-test-results
path: web/coverage
check-docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image
run: make docker-build
env:
MESHSTREAM_SITE_TITLE: "Meshstream Test"
MESHSTREAM_SITE_DESCRIPTION: "Meshtastic Network Monitoring Test"
- name: Check Docker image
run: docker images meshstream

View File

@@ -1,4 +1,4 @@
.PHONY: build run gen-proto clean tools web-run web-build web-test web-lint docker-build docker-run
.PHONY: build test run gen-proto clean tools web-run web-build web-test web-lint docker-build docker-run fmt fmt-check
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
@@ -17,6 +17,28 @@ build:
mkdir -p dist
go build -o dist/meshstream
# Test the server
test: vet
go test ./... -v
# Check Go formatting
fmt:
gofmt -w $(shell find . -name "*.go" | grep -v "/generated/" | grep -v "/node_modules/")
# Check Go formatting without modifying files (returns non-zero if files need formatting)
fmt-check:
@echo "Checking Go formatting..."
@if [ "$$(gofmt -l $$(find . -name "*.go" | grep -v "/generated/" | grep -v "/node_modules/") | wc -l)" -gt 0 ]; then \
echo "The following files need to be formatted with go fmt:"; \
gofmt -l $$(find . -name "*.go" | grep -v "/generated/" | grep -v "/node_modules/"); \
exit 1; \
else \
echo "All Go files are properly formatted."; \
fi
vet:
go vet ./...
# Run the application with json log formatting
run: build
@./dist/meshstream --verbose 2>&1 | go tool github.com/dpup/logista

View File

@@ -1,5 +0,0 @@
{
"dependencies": {
"@eslint/js": "^9.25.1"
}
}

23
pnpm-lock.yaml generated
View File

@@ -1,23 +0,0 @@
lockfileVersion: '9.0'
settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
importers:
.:
dependencies:
'@eslint/js':
specifier: ^9.25.1
version: 9.25.1
packages:
'@eslint/js@9.25.1':
resolution: {integrity: sha512-dEIwmjntEx8u3Uvv+kr3PDeeArL8Hw07H9kyYxCjnM9pBjfEhk6uLXSchxxzgiwtRhhzVzqmUSDFBOi1TuZ7qg==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
snapshots:
'@eslint/js@9.25.1': {}