Smoke Test #3
This file contains 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: 'Smoke Test' | |
on: | |
workflow_dispatch: | |
inputs: | |
env: | |
description: AWS environment to check | |
required: true | |
type: 'string' | |
default: 'dev' | |
workflow_call: | |
inputs: | |
env: | |
description: AWS environment to check | |
required: true | |
type: 'string' | |
default: 'dev' | |
permissions: | |
id-token: write | |
contents: read | |
concurrency: | |
group: ${{ github.workflow }}-${{ inputs.env }} | |
cancel-in-progress: false | |
jobs: | |
smoke-test: | |
name: Smoke Test | |
runs-on: self-hosted | |
steps: | |
- uses: slackapi/[email protected] | |
name: Slack Starting | |
with: | |
method: chat.postMessage | |
token: ${{ secrets.SLACK_BOT_TOKEN }} | |
# Sends to dpc-deploys | |
payload: | | |
channel: "CMC1E4AEQ" | |
attachments: | |
- color: warning | |
text: "Smoke test of `${{ inputs.env }}` has started" | |
footer: "<${{ github.server_url}}/${{ github.repository}}/actions/runs/${{ github.run_id }}|Smoke Test - Build ${{ github.run_id }}>" | |
mrkdown_in: | |
- footer | |
- name: "Checkout code" | |
uses: actions/checkout@v4 | |
- name: "Set up JDK 11" | |
uses: actions/setup-java@v3 | |
with: | |
distribution: "corretto" | |
java-version: "11" | |
- name: Install Python | |
run: sudo dnf -y install python3 python3-pip | |
- name: Install Maven 3.6.3 | |
run: | | |
export PATH="$PATH:/opt/maven/bin" | |
echo "PATH=$PATH" >> $GITHUB_ENV | |
if mvn -v; then echo "Maven already installed" && exit 0; else echo "Installing Maven"; fi | |
tmpdir="$(mktemp -d)" | |
curl -LsS https://archive.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz | tar xzf - -C "$tmpdir" | |
sudo rm -rf /opt/maven | |
sudo mv "$tmpdir/apache-maven-3.6.3" /opt/maven | |
- name: Clean maven | |
run: | | |
mvn -ntp -U clean | |
- name: AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-region: ${{ vars.AWS_REGION }} | |
role-to-assume: arn:aws:iam::${{ secrets.ACCOUNT_ID }}:role/delegatedadmin/developer/dpc-${{ inputs.env == 'prod-sbx' && 'sbx' || inputs.env }}-github-actions | |
- name: Fetch admin host | |
id: fetch-admin-host | |
run: | | |
admin_host=`aws elbv2 describe-load-balancers --names dpc-${{ inputs.env }}-frontend-internal --query="LoadBalancers[0].DNSName" --output text` | |
echo "admin_host=$admin_host" >> "$GITHUB_OUTPUT" | |
echo "ELB_URL=http://$admin_host:9900/tasks" >> "$GITHUB_OUTPUT" | |
- name: Determine host | |
id: determine-host | |
run: | | |
if [ "${{ inputs.env }}" = 'prod' ]; then | |
HOST="http://${{ steps.fetch-admin-host.outputs.admin_host }}" | |
elif [ "${{ inputs.env }}" = 'prod-sbx' ]; then | |
HOST="https://sandbox.dpc.cms.gov" | |
else | |
HOST="https://${{ inputs.env }}.dpc.cms.gov" | |
fi | |
echo "HOST=$HOST" >> "$GITHUB_OUTPUT" | |
echo "HOST_URL=$HOST/api/v1" >> "$GITHUB_OUTPUT" | |
- name: Run Smoke Test | |
id: run-smoke-test | |
env: | |
ELB_URL: ${{ steps.fetch-admin-host.outputs.ELB_URL }} | |
HOST_URL: ${{ steps.determine-host.outputs.HOST_URL }} | |
PORTAL_HOST: ${{ steps.determine-host.outputs.HOST }} | |
WEB_HOST: ${{ steps.determine-host.outputs.HOST }} | |
WEB_ADMIN_HOST: ${{ steps.determine-host.outputs.HOST }} | |
run: | | |
if [ "${{ inputs.env }}" = 'prod' ]; then | |
make smoke/prod | |
elif [ "${{ inputs.env }}" = 'prod-sbx' ]; then | |
make smoke/sandbox | |
else | |
make smoke/remote | |
fi | |
- name: Upload bzt logs | |
if: ${{ failure() && steps.run-smoke-test.outcome == 'failure' }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: bzt-logs | |
path: ./bzt-out | |
- uses: slackapi/[email protected] | |
name: Slack Success | |
with: | |
method: chat.postMessage | |
token: ${{ secrets.SLACK_BOT_TOKEN }} | |
# Sends to dpc-deploys | |
payload: | | |
channel: "CMC1E4AEQ" | |
attachments: | |
- color: good | |
text: "Smoke test of `${{ inputs.env }}` has succeeded" | |
footer: "<${{ github.server_url}}/${{ github.repository}}/actions/runs/${{ github.run_id }}|Smoke Test - Build ${{ github.run_id }}>" | |
mrkdown_in: | |
- footer | |
- uses: slackapi/[email protected] | |
name: Slack failure | |
if: ${{ failure() }} | |
with: | |
method: chat.postMessage | |
token: ${{ secrets.SLACK_BOT_TOKEN }} | |
# Sends to dpc-deploys | |
payload: | | |
channel: "CMC1E4AEQ" | |
attachments: | |
- color: danger | |
text: "Smoke test of `${{ inputs.env }}` has failed" | |
footer: "<${{ github.server_url}}/${{ github.repository}}/actions/runs/${{ github.run_id }}|Smoke Test - Build ${{ github.run_id }}>" | |
mrkdown_in: | |
- footer |