Feature/generic runner #1
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: moq-test-ui-image | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - 'v*' | |
| paths: | |
| - '.github/workflows/moq-test-ui-image.yml' | |
| - 'moq-test-ui/**' | |
| pull_request: | |
| paths: | |
| - '.github/workflows/moq-test-ui-image.yml' | |
| - 'moq-test-ui/**' | |
| workflow_dispatch: | |
| concurrency: | |
| group: moq-test-ui-image-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/moq-test-ui | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: moq-test-ui | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Start server | |
| run: | | |
| node src/server.js > /tmp/moq-test-ui.log 2>&1 & | |
| echo $! > /tmp/moq-test-ui.pid | |
| - name: Smoke test HTTP endpoint | |
| run: | | |
| for _ in $(seq 1 20); do | |
| if curl -fsS http://127.0.0.1:3000/api/tools >/dev/null; then | |
| exit 0 | |
| fi | |
| sleep 1 | |
| done | |
| cat /tmp/moq-test-ui.log | |
| exit 1 | |
| - name: Stop server | |
| if: always() | |
| run: | | |
| if [ -f /tmp/moq-test-ui.pid ]; then | |
| kill "$(cat /tmp/moq-test-ui.pid)" || true | |
| fi | |
| docker: | |
| runs-on: ubuntu-latest | |
| needs: test | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GHCR | |
| if: github.event_name != 'pull_request' | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract Docker metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| type=ref,event=branch | |
| type=ref,event=pr | |
| type=semver,pattern={{version}} | |
| type=sha | |
| - name: Build container image | |
| id: build | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: ./moq-test-ui | |
| file: ./moq-test-ui/Dockerfile | |
| platforms: linux/amd64 | |
| push: ${{ github.event_name != 'pull_request' }} | |
| load: ${{ github.event_name == 'pull_request' }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| - name: Smoke test container image | |
| if: github.event_name == 'pull_request' | |
| run: | | |
| docker run -d --rm --name moq-test-ui-smoke -p 3000:3000 "${{ env.IMAGE_NAME }}:pr-${{ github.event.pull_request.number }}" | |
| for _ in $(seq 1 20); do | |
| if curl -fsS http://127.0.0.1:3000/api/tools >/dev/null; then | |
| docker logs moq-test-ui-smoke | |
| docker stop moq-test-ui-smoke | |
| exit 0 | |
| fi | |
| sleep 1 | |
| done | |
| docker logs moq-test-ui-smoke | |
| docker stop moq-test-ui-smoke | |
| exit 1 |