Skip to content

Commit

Permalink
test v1.1.1-rc2
Browse files Browse the repository at this point in the history
Moved scripts used in workflows to be in the .github/workflows directory
  • Loading branch information
elrayle committed Jul 9, 2024
1 parent 783d934 commit 995ca9b
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 21 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/app-build-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This workflow will build a docker image, push it to ghcr.io, and deploy it to an Azure WebApp.
# v1.1.1-rc1 - This tag coordinates the other reusable parts of this workflow.
# v1.1.1-rc2 - This tag coordinates the other reusable parts of this workflow.
# * app-build-docker-image.yml
# * app-deploy-to-azure.yml
# * app-is-deployable.yml
Expand Down Expand Up @@ -76,7 +76,7 @@ jobs:
build-and-publish-image:
name: Build and publish Docker image
needs: get-version
uses: clearlydefined/operations/.github/workflows/[email protected]rc1
uses: clearlydefined/operations/.github/workflows/[email protected]rc2
secrets:
DEPLOY_TOKEN: ${{ secrets.DEPLOY_TOKEN }}
PRODUCTION_DEPLOYERS: ${{ secrets.PRODUCTION_DEPLOYERS }}
Expand All @@ -88,7 +88,7 @@ jobs:
deploy-primary-app-to-azure:
name: Deploy to primary Azure app
needs: [get-version, build-and-publish-image]
uses: clearlydefined/operations/.github/workflows/[email protected]rc1
uses: clearlydefined/operations/.github/workflows/[email protected]rc2
secrets:
AZURE_WEBAPP_PUBLISH_PROFILE: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
Expand All @@ -104,7 +104,7 @@ jobs:
name: Deploy to secondary Azure app
if: ${{ inputs.secondary-azure-app-name-postfix != '' }}
needs: [get-version, build-and-publish-image]
uses: clearlydefined/operations/.github/workflows/[email protected]rc1
uses: clearlydefined/operations/.github/workflows/[email protected]rc2
secrets:
AZURE_WEBAPP_PUBLISH_PROFILE: ${{ secrets.AZURE_SECONDARY_WEBAPP_PUBLISH_PROFILE }}
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/app-build-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ on:

jobs:
check-deployable:
uses: clearlydefined/operations/.github/workflows/[email protected]rc1
uses: clearlydefined/operations/.github/workflows/[email protected]rc2
with:
deploy-env: ${{ inputs.deploy-env }}
secrets:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/app-deploy-to-azure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ on:

jobs:
check-deployable:
uses: clearlydefined/operations/.github/workflows/[email protected]rc1
uses: clearlydefined/operations/.github/workflows/[email protected]rc2
with:
deploy-env: ${{ inputs.deploy-env }}
secrets:
Expand All @@ -55,7 +55,7 @@ jobs:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- name: Set DOCKER configs in Azure web app
uses: azure/[email protected]rc1
uses: azure/[email protected]rc2
with:
app-name: ${{ inputs.azure-webapp-name }}
app-settings-json: |
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ jobs:
sudo ./install.sh /usr/local
- name: Run Bats tests
run: bats tests/scripts/app-workflows/*.bats
run: bats .github/workflows/tests/scripts/app-workflows/*.bats
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
load 'test_helpers'

@test "deploy to dev environment" {
run ./scripts/app-workflows/confirm-dev.sh dev
run ./.github/workflows/scripts/app-workflows/confirm-dev.sh dev
test_value 0 "$status"
test_value "Deploying to dev environment" "${lines[0]}"
test_value "confirm-dev -> outputs -> is_dev: true" "${lines[1]}"
test_value true "${lines[2]}"
}

@test "deploy to prod environment" {
run ./scripts/app-workflows/confirm-dev.sh prod
run ./.github/workflows/scripts/app-workflows/confirm-dev.sh prod
test_value 0 "$status"
test_value "Deploying to prod or UNKNOWN environment" "${lines[0]}"
test_value "confirm-dev -> outputs -> is_dev: false" "${lines[1]}"
test_value false "${lines[2]}"
}

@test "deploy to anything else defaults to prod environment for tighter restrictions" {
run ./scripts/app-workflows/confirm-dev.sh UNKNOWN_ENV
run ./.github/workflows/scripts/app-workflows/confirm-dev.sh UNKNOWN_ENV
test_value 0 "$status"
test_value "Deploying to prod or UNKNOWN environment" "${lines[0]}"
test_value "confirm-dev -> outputs -> is_dev: false" "${lines[1]}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
load 'test_helpers'

@test "deploy to dev environment" {
run ./scripts/app-workflows/determine-image-name.sh test-org/test-repo dev test-tag
run ./.github/workflows/scripts/app-workflows/determine-image-name.sh test-org/test-repo dev test-tag
test_value 0 "$status"
test_value "determine_image_name -> outputs -> image_name_with_tag: ghcr.io/test-org/test-repo-dev:test-tag" "${lines[0]}"
test_value ghcr.io/test-org/test-repo-dev:test-tag "${lines[1]}"
}

@test "deploy to prod environment" {
run ./scripts/app-workflows/determine-image-name.sh test-org/test-repo prod test-tag
run ./.github/workflows/scripts/app-workflows/determine-image-name.sh test-org/test-repo prod test-tag
test_value 0 "$status"
test_value "determine_image_name -> outputs -> image_name_with_tag: ghcr.io/test-org/test-repo:test-tag" "${lines[0]}"
test_value ghcr.io/test-org/test-repo:test-tag "${lines[1]}"
}

@test "invalid deploy environment" {
run ./scripts/app-workflows/determine-image-name.sh test-org/test-repo BAD_ENV test-tag
run ./.github/workflows/scripts/app-workflows/determine-image-name.sh test-org/test-repo BAD_ENV test-tag
test_value 1 "$status"
test_value "Invalid deploy environment: BAD_ENV. Must be 'dev' or 'prod'" "${lines[0]}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
load 'test_helpers'

@test "get github org id" {
run ./scripts/app-workflows/get-org-id.sh "github"
run ./.github/workflows/scripts/app-workflows/get-org-id.sh "github"
test_value 0 "$status"
test_value "get-org-id -> outputs -> org_id: 9919" "${lines[0]}"
test_value "9919" "${lines[1]}"
}

@test "missing org name" {
run ./scripts/app-workflows/get-org-id.sh ""
run ./.github/workflows/scripts/app-workflows/get-org-id.sh ""
test_value 1 "$status"
test_value "Organization not found: " "${lines[0]}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,37 @@ load 'test_helpers'
package_lock_file="$(dirname "$BATS_TEST_DIRNAME")/app-workflows/fixtures/package-lock.json"

@test "deploy to dev environment" {
run ./scripts/app-workflows/get-version.sh dev false "" 1234567890ABCDEF "$package_lock_file"
run ./.github/workflows/scripts/app-workflows/get-version.sh dev false "" 1234567890ABCDEF "$package_lock_file"
test_value 0 "$status"
test_value "get-version.sh -> outputs -> version: v10.0.1-dev-1234567890" "${lines[0]}"
test_value "v10.0.1-dev-1234567890" "${lines[1]}"
}

@test "deploy to prod environment triggered by release and version matches" {
# only use version from package-lock.json if it matches the release tag
run ./scripts/app-workflows/get-version.sh prod true v10.0.1 1234567890ABCDEF "$package_lock_file"
run ./.github/workflows/scripts/app-workflows/get-version.sh prod true v10.0.1 1234567890ABCDEF "$package_lock_file"
test_value 0 "$status"
test_value "get-version.sh -> outputs -> version: v10.0.1" "${lines[0]}"
test_value "v10.0.1" "${lines[1]}"
}

@test "deploy to prod environment triggered by release and version doesn't matches" {
# fail because version in package-lock.json doesn't match the release tag
run ./scripts/app-workflows/get-version.sh prod true v9.2.0 1234567890ABCDEF "$package_lock_file"
run ./.github/workflows/scripts/app-workflows/get-version.sh prod true v9.2.0 1234567890ABCDEF "$package_lock_file"
test_value 1 "$status"
test_value "Version in package-lock.json (v10.0.1) does not match the release tag (v9.2.0)" "${lines[0]}"
}

@test "deploy to prod environment triggered by dispatch" {
# always uses version from package-lock.json when triggered by a dispatch
run ./scripts/app-workflows/get-version.sh prod false v9.2.0 1234567890ABCDEF "$package_lock_file"
run ./.github/workflows/scripts/app-workflows/get-version.sh prod false v9.2.0 1234567890ABCDEF "$package_lock_file"
test_value 0 "$status"
test_value "get-version.sh -> outputs -> version: v10.0.1" "${lines[0]}"
test_value "v10.0.1" "${lines[1]}"
}

@test "invalid deploy environment" {
run ./scripts/app-workflows/get-version.sh BAD_ENV false v9.2.0 1234567890ABCDEF "$package_lock_file"
run ./.github/workflows/scripts/app-workflows/get-version.sh BAD_ENV false v9.2.0 1234567890ABCDEF "$package_lock_file"
test_value 1 "$status"
test_value "Invalid deploy environment: BAD_ENV. Must be 'dev' or 'prod'" "${lines[0]}"
}

0 comments on commit 995ca9b

Please sign in to comment.