Skip to content

integration-test

integration-test #5181

on:
push:
branches:
- main
pull_request:
types: [opened, reopened, labeled, unlabeled, synchronize]
branches:
- main
label: {}
schedule:
- cron: '0 11 * * *'
workflow_dispatch:
name: integration-test
jobs:
filter:
runs-on: [ARM64, self-hosted, Linux]
outputs:
should_run_integration_tests: ${{ steps.check_branch.outputs.result }}
steps:
- name: Print GitHub Context
env:
GITHUB_CONTEXT: ${{ toJson(github.event.pull_request) }}
run: |
echo "$GITHUB_CONTEXT"
- name: Check if integration-test file changed
# the output of this step is only used if the run was triggered by a pull_request
if: ${{ github.event_name == 'pull_request' }}
uses: dorny/paths-filter@v2
id: integration_test_changes
with:
filters: |
dependencies:
- '.github/workflows/integration-test.yml'
- name: Check for if the head branch is the release-please branch, or if the PR has the happy:integration-test label
id: check_branch
uses: actions/github-script@v6
with:
script: |
if ('${{ github.event_name }}' === 'pull_request') {
return ${{ steps.integration_test_changes.outputs.dependencies == 'true' }} || ${{ github.head_ref == 'release-please--branches--main' }} ||
${{ contains(github.event.pull_request.labels.*.name, 'happy:integration-test') }} ;
}
// run for all non-pull_request triggers (ie, pushes to main, workflow_dispatch)
return true
integration-test:
needs: filter
if: ${{ needs.filter.outputs.should_run_integration_tests == 'true' }}
runs-on: [ARM64, self-hosted, Linux]
timeout-minutes: 20
permissions:
id-token: write
contents: read
env:
TFE_TOKEN: ${{ secrets.TFE_TOKEN_PLAYGROUND }}
steps:
- run: |
mkdir -p ~/.ssh/
ssh-keyscan -H github.com >> ~/.ssh/known_hosts
- name: Install SSH key
uses: webfactory/[email protected]
with:
ssh-private-key: |
${{ secrets.SHARED_INFRA_DEPLOY_KEY }}
- name: Assume happy-api deployement role
uses: aws-actions/configure-aws-credentials@v2
with:
aws-region: us-west-2
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME_INTEGRATION_PLAYGROUND }}
role-duration-seconds: 1200
role-session-name: HappyCLIIntegrationTest
- uses: azure/setup-kubectl@v3
- name: Install AWS CLI
id: install-aws-cli
uses: unfor19/install-aws-cli-action@master
with:
arch: arm64
version: 2
- name: Debug
run: |
aws eks list-clusters --region us-west-2
aws eks update-kubeconfig --name si-playground-eks-v2 --region us-west-2
kubectl get nodes
kubectl get secret integration-secret -n si-rdev-happy-eks-rdev-happy-env
- name: Install Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.3.0
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version-file: cli/go.mod
cache: true
- name: Get go cache paths
id: cache-paths
run: |
echo "gocache=$(go env GOCACHE)" >> $GITHUB_OUTPUT
echo "gomodcache=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT
- name: Cache Go modules
uses: actions/cache@v3
with:
path: |
${{steps.cache-paths.outputs.gocache}}
${{steps.cache-paths.outputs.gomodcache}}
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build CLI
run: |
go mod tidy
go build -o happy
working-directory: ./cli
- name: Get Stack Name
id: get-stack-name
run: |
SHORT_SHA=$(git rev-parse --short ${{ github.sha }})
echo "stack_name=integration-test-$SHORT_SHA" >> $GITHUB_OUTPUT
- name: List stacks
run: ../../cli/happy --detached --aws-profile="" list -v
working-directory: ./examples/integration_test
- name: Delete a stack
run: ../../cli/happy --detached --aws-profile="" delete ${{steps.get-stack-name.outputs.stack_name}} -v || true
working-directory: ./examples/integration_test
- name: List stacks
run: |
MATCHING_STACK_COUNT=$(../../cli/happy --detached --aws-profile="" list --output json | jq '[.[] | select(.stack=="${{steps.get-stack-name.outputs.stack_name}}")] | length')
if [ "$MATCHING_STACK_COUNT" != "0" ]; then
echo "Expected 0 stacks, got $MATCHING_STACK_COUNT"
exit 1
else
echo "Stack was deleted, as expected"
fi
working-directory: ./examples/integration_test
- name: Build an image
run: ../../cli/happy --detached --aws-profile="" build
working-directory: ./examples/integration_test
- name: Validate TF code
run: ../../cli/happy --detached --aws-profile="" infra validate --force
working-directory: ./examples/integration_test
- name: Ingest TF code
run: ../../cli/happy --detached --aws-profile="" infra ingest --force
working-directory: ./examples/integration_test
- name: Generate TF code
run: ../../cli/happy --detached --aws-profile="" infra generate --force
working-directory: ./examples/integration_test
- name: Ingest TF code
run: ../../cli/happy --detached --aws-profile="" infra refresh --pin main --force
working-directory: ./examples/integration_test
- name: Create a stack
run: ../../cli/happy --detached --aws-profile="" create ${{steps.get-stack-name.outputs.stack_name}} -v --tag integrationtest --force
working-directory: ./examples/integration_test
- name: List stacks
run: |
MATCHING_STACK_COUNT=$(../../cli/happy --detached --aws-profile="" list --output json | jq '[.[] | select(.stack=="${{steps.get-stack-name.outputs.stack_name}}")] | length')
if [ "$MATCHING_STACK_COUNT" != "1" ]; then
echo "Expected 1 stack, got $MATCHING_STACK_COUNT"
exit 1
else
echo "Found 1 stack, as expected"
fi
working-directory: ./examples/integration_test
- name: Push an image
run: ../../cli/happy --detached --aws-profile="" push ${{steps.get-stack-name.outputs.stack_name}} --tag integrationtest
working-directory: ./examples/integration_test
- name: Get events
run: ../../cli/happy --detached --aws-profile="" events ${{steps.get-stack-name.outputs.stack_name}} -v
working-directory: ./examples/integration_test
- name: Update a stack
run: ../../cli/happy --detached --aws-profile="" update ${{steps.get-stack-name.outputs.stack_name}} -v --tag integrationtest
working-directory: ./examples/integration_test
- name: Get stack logs
run: ../../cli/happy --detached --aws-profile="" logs ${{steps.get-stack-name.outputs.stack_name}} frontend -v
working-directory: ./examples/integration_test
- name: Get stack resources
run: ../../cli/happy --detached --aws-profile="" resources ${{steps.get-stack-name.outputs.stack_name}} -v
working-directory: ./examples/integration_test
- name: Get stack
run: ../../cli/happy --detached --aws-profile="" get ${{steps.get-stack-name.outputs.stack_name}} -v
working-directory: ./examples/integration_test
- name: Delete a stack
run: ../../cli/happy --detached --aws-profile="" delete ${{steps.get-stack-name.outputs.stack_name}} -v --force || true
working-directory: ./examples/integration_test
- name: List stacks
run: |
MATCHING_STACK_COUNT=$(../../cli/happy --detached --aws-profile="" list --output json | jq '[.[] | select(.stack=="${{steps.get-stack-name.outputs.stack_name}}")] | length')
if [ "$MATCHING_STACK_COUNT" != "0" ]; then
echo "Expected 0 stacks, got $MATCHING_STACK_COUNT"
exit 1
else
echo "Stack was deleted, as expected"
fi
working-directory: ./examples/integration_test