Skip to content

Commit

Permalink
use pattern to update images for release pipline.
Browse files Browse the repository at this point in the history
Test both UI and API when verifying deployed version.
run integration tests after deploy to staging
run deploy to prod after integration tests
  • Loading branch information
hahn-kev committed Oct 24, 2023
1 parent 2e4bbba commit dd9e28b
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 26 deletions.
49 changes: 37 additions & 12 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ on:
description: 'The image to update'
type: string
required: true
health-endpoint:
description: 'The health endpoint to check'
deploy-domain:
description: 'The domain to check for deployment'
type: string
required: true
k8s-environment:
Expand All @@ -25,11 +25,11 @@ on:
type: string
required: true
image:
description: 'The image to update'
description: 'The image to update, can use * to update all images'
type: string
required: true
health-endpoint:
description: 'The health endpoint to check'
deploy-domain:
description: 'The domain to check for deployment'
type: string
required: true
k8s-environment:
Expand All @@ -42,6 +42,12 @@ jobs:
# deploy checks out the fleet repo, we don't want more than one just running at once to avoid conflicts
concurrency: deploy
runs-on: ubuntu-latest
environment:
name: ${{ inputs.k8s-environment }}
url: https://${{ inputs.deploy-domain }}
outputs:
api-version: ${{ steps.get-api-version.outputs.result }}
ui-version: ${{ steps.get-ui-version.outputs.result }}
steps:
- name: Checkout lexbox repo
uses: actions/checkout@v3
Expand All @@ -64,23 +70,44 @@ jobs:
- name: Update image version in fleet kustomization.yaml
uses: mikefarah/[email protected]
with:
cmd: yq eval -i '(.images.[] | select(.name == "${{ inputs.image }}").newTag) = "${{ inputs.version }}"' "fleet/languageforge-lexbox/kustomization.yaml"
cmd: yq eval -i '(.images.[] | select(.name == "${{ inputs.image }}").newTag) = "${{ inputs.version }}"' "fleet/${{ inputs.k8s-environment }}/kustomization.yaml"
- name: Get API version
uses: mikefarah/[email protected]
id: get-api-version
with:
cmd: yq '.images.[] | select(.name == "ghcr.io/sillsdev/lexbox-api").newTag' "fleet/${{ inputs.k8s-environment }}/kustomization.yaml"
- name: Get UI version
uses: mikefarah/[email protected]
id: get-ui-version
with:
cmd: yq '.images.[] | select(.name == "ghcr.io/sillsdev/lexbox-ui").newTag' "fleet/${{ inputs.k8s-environment }}/kustomization.yaml"
- name: Push to fleet repo
uses: EndBug/add-and-commit@v9 #https://github.com/EndBug/add-and-commit
with:
default_author: github_actions
message: "[Lexbox] Update ${{ inputs.k8s-environment }} image: ${{ inputs.image }} to ${{ inputs.version }}"
cwd: './fleet/'
add: 'languageforge-lexbox/*'
push: true
add: '${{ inputs.k8s-environment }}/*'
push: false
verify-published:
name: Verify ${{ matrix.verify.name }} Published
runs-on: ubuntu-latest
needs: deploy
strategy:
fail-fast: true
matrix:
verify:
- version: ${{ needs.deploy.outputs.api-version }}
endpoint: ${{ inputs.deploy-domain }}/api/healthz
name: API
- version: ${{ needs.deploy.outputs.ui-version }}
endpoint: ${{ inputs.deploy-domain }}/healthz
name: UI
steps:
- name: Verify Version
env:
TARGET_ENDPOINT: ${{ inputs.health-endpoint }}
EXPECTED_VERSION: ${{ inputs.version }}
TARGET_ENDPOINT: ${{ matrix.verify.endpoint }}
EXPECTED_VERSION: ${{ matrix.verify.version }}
run: |
IterateCount=10
DelayMultiplier=5
Expand All @@ -95,8 +122,6 @@ jobs:
exit 0
else
echo "Version '$versionHeader' is incorrect, expected '$EXPECTED_VERSION'"
echo "response was:"
cat response.txt
n=$((n+1))
sleep $((DelayMultiplier * n))
fi
Expand Down
21 changes: 16 additions & 5 deletions .github/workflows/integration-test.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
name: Integration Tests
on:
workflow_call:
inputs:
test-domain:
description: 'The environment to run the tests in'
required: true
type: string
default: 'staging.languagedepot.org'
workflow_dispatch:

inputs:
test-domain:
description: 'The environment to run the tests in'
required: true
type: string
default: 'staging.languagedepot.org'

jobs:
test:
timeout-minutes: 60
concurrency: test-staging
name: ${{ matrix.os }}
concurrency: test-${{ inputs.test-domain }}
name: Test ${{ matrix.os }} on ${{ inputs.test-domain }}
permissions:
checks: write
strategy:
Expand Down Expand Up @@ -42,10 +53,10 @@ jobs:
run: pwsh backend/Testing/bin/Debug/net7.0/playwright.ps1 install
- name: Integration tests
env:
TEST_SERVER_HOSTNAME: staging.languagedepot.org
TEST_SERVER_HOSTNAME: ${{ inputs.test-domain }}
# this is not a typo, we need to use the lf domain because it has a cert that hg will validate
TEST_STANDARD_HG_HOSTNAME: hg-staging.languageforge.org
TEST_RESUMABLE_HG_HOSTNAME: resumable-staging.languagedepot.org
TEST_RESUMABLE_HG_HOSTNAME: resumable-${{ inputs.test-domain }}
TEST_PROJECT_CODE: 'sena-3'
TEST_DEFAULT_PASSWORD: ${{ secrets.TEST_USER_PASSWORD }}
run: dotnet test --output ./bin --logger trx --results-directory ./test-results --filter Category=Integration
Expand Down
22 changes: 17 additions & 5 deletions .github/workflows/lexbox-hgweb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,34 @@ on:
- 'hgweb/**'
- '.github/workflows/lexbox-hgweb.yaml'
branches:
- main
- develop
pull_request:
paths:
- 'hgweb/**'
- '.github/workflows/lexbox-hgweb.yaml'
branches:
- main
- develop
workflow_call:
inputs:
version:
description: 'The version of the image to build'
required: true
type: string
label-latest:
description: 'The label to apply to the latest image'
type: boolean
default: false

env:
PROD_RELEASE: ${{github.ref == vars.PROD_BRANCH}}
PROD_RELEASE: ${{ inputs.label-latest}}
IMAGE_NAME: ghcr.io/sillsdev/lexbox-hgweb
VERSION: ${{ inputs.version }}

jobs:
publish-hgweb:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.setVersion.outputs.VERSION }}
version: ${{ inputs.version || steps.setVersion.outputs.VERSION }}

env:
# https://docs.docker.com/develop/develop-images/build_enhancements/
Expand All @@ -36,6 +45,7 @@ jobs:
uses: actions/checkout@v3
- name: Set Version
id: setVersion
if: ${{ !env.VERSION }}
# set version to date in vYYYY-MM-DD format
run: |
echo "VERSION=v$(date --rfc-3339=date)" >> ${GITHUB_ENV}
Expand Down Expand Up @@ -69,9 +79,11 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
deploy-hgweb:
uses: ./.github/workflows/deploy.yaml
if: ${{github.ref == vars.PROD_BRANCH}}
if: ${{github.ref == 'refs/heads/develop'}}
secrets: inherit
needs: publish-hgweb
with:
version: ${{ needs.publish-hgweb.outputs.version }}
image: 'ghcr.io/sillsdev/lexbox-hgweb'
deploy-domain: 'staging.languagedepot.org'
k8s-environment: 'dev'
35 changes: 31 additions & 4 deletions .github/workflows/release-pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,41 @@ jobs:
version: ${{ needs.set-version.outputs.version }}
label-latest: true

build-hgweb:
name: Build hgweb
needs: [ set-version ]
uses: ./.github/workflows/lexbox-hgweb.yaml
with:
version: ${{ needs.set-version.outputs.version }}
label-latest: true

deploy:
name: Deploy
uses: ./.github/workflows/deploy.yaml
needs: [ build-api, build-ui, set-version ]
needs: [ build-api, build-ui, build-hgweb, set-version ]
with:
version: ${{ needs.set-version.outputs.version }}
image: 'ghcr.io/sillsdev/lexbox-api' # todo need to be able to update more than one image at a time
k8s-environment: staging #
health-endpoint: https://staging.languagedepot.org/api/healthz
image: 'ghcr.io/sillsdev/lexbox-*'
k8s-environment: staging
deploy-domain: staging.languagedepot.org

integration-tests:
name: Integration tests
uses: ./.github/workflows/integration-test.yaml
permissions:
checks: write
secrets: inherit
needs: deploy
with:
test-domain: staging.languagedepot.org

deploy-prod:
name: Deploy
uses: ./.github/workflows/deploy.yaml
needs: [ integration-tests, set-version ]
with:
version: ${{ needs.set-version.outputs.version }}
image: 'ghcr.io/sillsdev/lexbox-*'
k8s-environment: production
deploy-domain: prod.languagedepot.org

0 comments on commit dd9e28b

Please sign in to comment.