Skip to content

add pwa flush edit test #103

add pwa flush edit test

add pwa flush edit test #103

Workflow file for this run

name: Build and test PWA image
on:
push:
paths:
- pwa/**
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-pwa:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
with:
images: ghcr.io/pgulb/flush-log
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
context: ./pwa/
push: ${{ github.event_name != 'pull_request' }}
tags: ghcr.io/pgulb/flush-log:pwa
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
pwa-test:
needs: [build-pwa]
runs-on: ubuntu-latest
services:
pwa:
image: ghcr.io/pgulb/flush-log:pwa
ports:
- 8080:8080
env:
GOAPP_PORT: ':8080'
mongo:
image: mongo:8.0.1-noble
options: >-
--health-cmd "echo 'db.runCommand("ping").ok' | mongosh --quiet"
--health-interval 10s
--health-timeout 5s
--health-retries 5
--name mongo_container
ports:
- 27017:27017
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go environment
uses: actions/setup-go@v5.0.2
with:
go-version: '1.23.2'
- name: Install curl
run: sudo apt-get update && sudo apt-get install -y curl
- name: Install go-task
run: sudo sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b /usr/local/bin
- name: Install netcat
run: sudo apt-get update && sudo apt-get install -y netcat-traditional
- name: Build test API image
run: docker build -t flush-log:api -f ./api/Dockerfile ./api/
- name: run API
run: docker run --name api -d -p 6789:6789 --net=host -e MONGO_URL='mongodb://localhost:27017/?connectTimeoutMS=3000&timeoutMS=4000&socketTimeoutMS=3000&serverSelectionTimeoutMS=4000' flush-log:api
- name: wait for a while
run: sleep 15
- name: check pwa with nc
run: nc -vz localhost 8080
- name: check api with nc
run: nc -vz localhost 6789
- name: check mongo with nc
run: nc -vz localhost 27017
- name: check api readiness with curl
run: curl --fail http://localhost:6789/readyz
- name: run unit tests
run: task test-pwa-unit
- name: run integration tests
run: task test-pwa-integration