Skip to content

Commit

Permalink
First pass at consolidating workflows (#292)
Browse files Browse the repository at this point in the history
  • Loading branch information
emilymclean authored Sep 25, 2024
2 parents ded2c4f + e817b06 commit 3198514
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 138 deletions.
33 changes: 25 additions & 8 deletions .github/workflows/deploy.yaml → .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ name: Build
on:
push:
branches: [ main ]
workflow_dispatch:
pull_request:

jobs:
version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.gitversion.outputs.semVer }}

steps:
- name: Check out code
uses: actions/checkout@v2
Expand All @@ -30,10 +29,10 @@ jobs:
- name: Display SemVer
run: |
echo "SemVer: ${{ steps.gitversion.outputs.semVer }}"
release:
runs-on: ubuntu-latest
needs: version
if: github.event_name != 'pull_request'
permissions:
contents: write
steps:
Expand Down Expand Up @@ -61,7 +60,6 @@ jobs:
asset_path: ./fireapp-${{ needs.version.outputs.version }}.zip
asset_name: fireapp-${{ needs.version.outputs.version }}.zip
asset_content_type: application/zip

docker:
runs-on: ubuntu-latest
needs: version
Expand All @@ -75,12 +73,17 @@ jobs:
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Lowercase Repository
run: |
echo "REPOSITORY_LC=${REPOSITORY,,}" >> ${GITHUB_ENV}
env:
REPOSITORY: '${{ github.repository }}'
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/techlauncherfireapp/backend
ghcr.io/${{ env.REPOSITORY_LC }}
tags: |
type=schedule
type=ref,event=branch
Expand All @@ -95,13 +98,27 @@ jobs:
registry: https://ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- run: |
if [[ "${{ github.event_name != 'pull_request' }}" == "true" ]]; then
echo "TAGS=${{ steps.meta.outputs.tags }}
ghcr.io/${{ env.REPOSITORY_LC }}:latest
ghcr.io/${{ env.REPOSITORY_LC }}:${{ needs.version.outputs.version }}" >> $GITHUB_ENV
else
echo "TAGS=ghcr.io/${{ env.REPOSITORY_LC }}:${{ needs.version.outputs.version }}" >> $GITHUB_ENV
fi
id: tag
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64, linux/arm64, linux/riscv64, linux/arm/v7, linux/arm/v6
push: true
tags: |
${{ steps.meta.outputs.tags }}
ghcr.io/techlauncherfireapp/backend:latest
ghcr.io/techlauncherfireapp/backend:${{ needs.version.outputs.version }}
${{ env.TAGS }}
call_test:
needs:
- docker
- version
uses: ./.github/workflows/test.yml
with:
version: ${{ needs.version.outputs.version }}
54 changes: 0 additions & 54 deletions .github/workflows/docker-pr.yml

This file was deleted.

39 changes: 0 additions & 39 deletions .github/workflows/pytest.yml

This file was deleted.

74 changes: 37 additions & 37 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
name: Test

on:
workflow_run:
workflows:
- deploy
- "Build"
branches:
- main
types:
- completed
workflow_call:
inputs:
version:
required: true
type: string

jobs:
version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.gitversion.outputs.semVer }}

steps:
- name: Check out code
uses: actions/checkout@v2
with:
fetch-depth: '0'
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '5.x'
- name: Use GitVersion
id: gitversion # step id used as reference for output values
uses: gittools/actions/gitversion/[email protected]
with:
useConfigFile: true
showConfig: true
configFilePath: ./GitVersion.yml
- name: Display SemVer
run: |
echo "SemVer: ${{ steps.gitversion.outputs.semVer }}"
smoke:
runs-on: ubuntu-latest
needs:
- version
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Lowercase Repository
run: |
echo "REPOSITORY_LC=${REPOSITORY,,}" >> ${GITHUB_ENV}
env:
REPOSITORY: '${{ github.repository }}'
- name: Download docker compose config
run: wget https://raw.githubusercontent.com/TechlauncherFireApp/docker/main/docker-compose.frontend.yml
run: wget https://raw.githubusercontent.com/${{ github.repository_owner }}/docker/main/docker-compose.frontend.yml
- name: Find and Replace
uses: jacobtomlinson/gha-find-replace@v3
with:
find: "ghcr.io/techlauncherfireapp/backend:latest"
replace: "ghcr.io/techlauncherfireapp/backend:${{ needs.version.outputs.version }}"
find: "ghcr.io/${{ env.REPOSITORY_LC }}:latest"
replace: "ghcr.io/${{ env.REPOSITORY_LC }}:${{ inputs.version }}"
regex: false
- name: Docker Compose version
run: docker compose version
- name: Start containers
run: docker compose -f "docker-compose.frontend.yml" up -d --wait
- name: Test container
run: docker run --network container:backend-fireapp-1 appropriate/curl -s --retry 10 --retry-connrefused http://localhost:5000/
pytest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install snapd
run: |
sudo apt update
sudo apt install snapd
- name: Install MiniZinc
run: |
sudo snap install minizinc --classic
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
pip install minizinc
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Test with pytest
run: |
pytest

0 comments on commit 3198514

Please sign in to comment.