Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(cb2-11268): upgrade aws-sdk to v3 #99

Merged
merged 14 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 43 additions & 75 deletions .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
name: 🧱 Build and Test
run-name: 🧱 Build and Test ${{ github.repository }}@${{ github.ref_name }}
run-name: 🧱 Build and Test ${{ github.ref_name }}
env:
bucket-name: cvs-services
on:
workflow_call:
workflow_dispatch:
inputs:
ignore-test-failures:
type: boolean
description: Ignore Test Failures
default: false

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true

permissions:
id-token: write
contents: write
Expand All @@ -19,11 +24,20 @@ jobs:
name: 🧹 Prepare Environment
runs-on: ubuntu-latest
outputs:
version-number: ${{ steps.version.outputs.version }}
environment-name: ${{ steps.environment.outputs.environment-name }}
environment-type: ${{ steps.environment.outputs.environment-type }}
github-branch: ${{ steps.environment.outputs.github-branch }}
commit: ${{ steps.commit.outputs.commit }}
package-name: ${{ steps.name.outputs.package-name }}

steps:
- name: Generate Package Name
id: name
run: |
repo=${{ github.repository }}
echo "package-name=${repo#dvsa/}" >> $GITHUB_OUTPUT
echo "Package Name: ${repo#dvsa/}" >> $GITHUB_STEP_SUMMARY

- name: 🪪 Get Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
Expand All @@ -42,11 +56,21 @@ jobs:
with:
environment: ${{ github.ref_name }}

build-services:
name: 🧱 Build ${{ github.ref_name }}
runs-on: [self-hosted, X64]
needs: environment
- name: Get Commit SHA
id: commit
run: |
# Get the branch Commit ID
commit_id=$(git rev-parse HEAD)
echo "commit=${commit_id}"
echo "commit=${commit_id}" >> $GITHUB_OUTPUT
echo "Commit ID: ${commit_id}" >> $GITHUB_STEP_SUMMARY

build-service:
name: 🧱 Build ${{ needs.environment.outputs.package-name }}
runs-on:
- ${{ needs.environment.outputs.package-name }}

needs: environment
steps:
- name: 🪪 Get Credentials
uses: aws-actions/configure-aws-credentials@v4
Expand All @@ -57,36 +81,27 @@ jobs:

- name: 📥 Get Codebase
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
ref: ${{ github.ref_name }}

- name: Get Commit SHA
id: commit
run: |
# Get the branch Commit ID
commit_id=$(git rev-parse HEAD)
echo "commit=${commit_id}"
echo "commit=${commit_id}" >> $GITHUB_OUTPUT
echo "Commit ID: ${commit_id}" >> $GITHUB_STEP_SUMMARY

- name: 🗒️ Process Manifest Data
id: manifest
run: |
# Generate Manifest Outputs & Identify Build Requirements
echo "package-name=$(jq -r '.name' manifest.json)" >> $GITHUB_OUTPUT
echo "language=$(jq -r '.language' manifest.json)" >> $GITHUB_OUTPUT
echo "liquibase=$(jq -r '.liquibase' manifest.json)" >> $GITHUB_OUTPUT

# Generate Output File
jq -c '. += {"sha":"${{ steps.commit.outputs.commit }}","repository":"${{ github.repository }}"' manifest.json > outputs.json
hash_files="[]"
if [[ -f "manifest.json" ]]; then
package=$(jq -r '.name' manifest.json)
echo "package=$(jq -r '.name' manifest.json)" >> $GITHUB_OUTPUT
echo "language=$(jq -r '.language' manifest.json)" >> $GITHUB_OUTPUT
echo "liquibase=$(jq -r '.liquibase' manifest.json)" >> $GITHUB_OUTPUT
fi

- name: 🏗️ Build Node Function
uses: dvsa/cvs-github-actions/build-node-function@develop
if: ${{ steps.manifest.outputs.language == 'node' }}
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
with:
commit-sha: ${{ steps.commit.outputs.commit }}
branch: ${{ github.ref_name }}
commit-sha: ${{ needs.environment.outputs.commit }}
branch: ${{needs.environment.outputs.github-branch }}
mysql_liquibase: ${{ steps.manifest.outputs.liquibase }}
mysql_user: ${{ secrets.MYSQL_USER }}
mysql_password: ${{ secrets.MYSQL_PASS }}
Expand All @@ -99,53 +114,6 @@ jobs:
- name: 📤 Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ needs.environment.outputs.package-name }}
path: |
outputs.json
${{ steps.commit.outputs.commit }}*.zip

upload-functions:
# Runs as a separate job because we don't want to push anything if any one of the services fails to build
name: 🎯 Upload ${{ github.ref_name }}
runs-on: ubuntu-latest
needs: [environment, build-services]
steps:
- name: 🪪 Get Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.CVS_MGMT_AWS_ROLE }}
aws-region: ${{ vars.DVSA_AWS_REGION }}
role-session-name: GHA_BuildServices

- name: 📥 Download Artifact
uses: actions/download-artifact@v4

- name: 🗒️ Get Manifest Data
id: manifest
run: |
# Get information from Manifest File
echo "package-name=$(jq -r '.name' outputs.json)" >> $GITHUB_OUTPUT
echo "mono-repo=$(jq -r '.monorepo' outputs.json)" >> $GITHUB_OUTPUT
echo "sha=$(jq -r '.sha' outputs.json)" >> $GITHUB_OUTPUT
echo "build-package=$(jq -r '.build' outputs.json)" >> $GITHUB_OUTPUT
echo "hash-files=$(jq -r '.hash_files' outputs.json)" >> $GITHUB_OUTPUT

echo "package-name=$(jq -r '.name' outputs.json)" >> $GITHUB_STEP_SUMMARY
echo "mono-repo=$(jq -r '.monorepo' outputs.json)" >> $GITHUB_STEP_SUMMARY
echo "sha=$(jq -r '.sha' outputs.json)" >> $GITHUB_STEP_SUMMARY
echo "build-package=$(jq -r '.build' outputs.json)" >> $GITHUB_STEP_SUMMARY
echo "hash-files=$(jq -r '.hash_files' outputs.json)" >> $GITHUB_STEP_SUMMARY

- name: Create Hash Files
uses: dvsa/cvs-github-actions/hash-create@develop
with:
commit-id: ${{ steps.manifest.outputs.sha }}
environment-name: ${{ needs.environment.outputs.environment-name }}
hash-files: ${{ steps.manifest.outputs.hash-files }}

- name: 📤 Upload hash zip to S3
uses: dvsa/cvs-github-actions/hash-upload@develop
with:
commit-id: ${{ steps.manifest.outputs.sha }}
package-name: ${{ steps.manifest.outputs.package-name }}
environment-name: ${{ needs.environment.outputs.environment-name }}
version-number: ${{ needs.environment.outputs.version-number }}
${{ needs.environment.outputs.commit }}*.zip
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ On Windows, you will need to manually run:
* Confirm: `echo %USE_CONTAINERIZED_DATABASE%` should return `1`before the above, or run these tests with an IntelliJ configuration which sets the right environment variable for you.

On Tanio Artino's advice, there is a distinction between running integration tests locally, and running them on Jenkins.
* `USE_CONTAINERIZED_DATABASE=0` will attempt to talk to `localhost:3306`. This only works if you manually start a DB or, in the case of Jenkins, if there is a pre-existing DB running on port `3306`.
* `USE_CONTAINERIZED_DATABASE=0` will attempt to talk to `127.0.0.1:3306`. This only works if you manually start a DB or, in the case of Jenkins, if there is a pre-existing DB running on port `3306`.
* `USE_CONTAINERIZED_DATABASE=1` will spin up a TC container as described above.

To run the "Jenkins" version, e.g. `USE_CONTAINERIZED_DATABASE=0`, use:
Expand Down
Loading
Loading