Skip to content

Commit

Permalink
Update template-infra's infra check to install example project to run…
Browse files Browse the repository at this point in the history
… against
  • Loading branch information
doshitan committed Nov 5, 2024
1 parent 37a2962 commit 38922e1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 16 deletions.
32 changes: 31 additions & 1 deletion .github/workflows/template-only-ci-infra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,42 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Checkout template-infra repo
uses: actions/checkout@v4
with:
path: template-infra
# TODO: Revert to checking out main once we've merged the platform-cli branch into the main branch
ref: lorenyu/platform-cli

- uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.8.3
terraform_wrapper: false

- uses: actions/setup-go@v3
with:
go-version: ">=1.19.0"

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'

- name: Install nava-platform CLI
run: pipx install --python python3.13 git+https://github.com/navapbc/platform-cli

- name: Install infra template
run: |
nava-platform infra install --template-uri ./template-infra \
--data app_name=app \
--data local_port=3000 \
--data is_dev_env_setup=true \
project-dir
- name: Copy template-only things to project copy of template
run: |
cp -vr ./template-infra/template-only* ./project-dir
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v3
with:
Expand All @@ -56,7 +84,9 @@ jobs:
aws-secret-access-key: ${{ secrets.TESTER_AWS_SECRET_ACCESS_KEY }}

- name: Run Terratest
working-directory: project-dir
run: make -f template-only.mak test
env:
# GitHub token needed for GitHub CLI which is used during tests to check GitHub Actions auth
GH_TOKEN: ${{ secrets.PLATFORM_TESTER_GITHUB_TOKEN }}
IMAGE_TAG: ${{ github.sha }}
17 changes: 2 additions & 15 deletions template-only-test/template_infra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
var uniqueId = strings.ToLower(random.UniqueId())
var projectName = fmt.Sprintf("plt-tst-act-%s", uniqueId)

var imageTag = os.Getenv("IMAGE_TAG")

func TestEndToEnd(t *testing.T) {
defer TeardownAccount(t)
SetUpProject(t, projectName)
Expand Down Expand Up @@ -113,13 +115,6 @@ func SetUpDevEnvironment(t *testing.T) {
WorkingDir: "../",
})

// Get current commit hash, which should be the one that was deployed as part of validating the build-repository
imageTag := shell.RunCommandAndGetOutput(t, shell.Command{
Command: "git",
Args: []string{"rev-parse", "HEAD"},
WorkingDir: "./",
})

shell.RunCommand(t, shell.Command{
Command: "make",
Args: []string{"infra-update-app-service", "APP_NAME=app", "ENVIRONMENT=dev"},
Expand Down Expand Up @@ -241,11 +236,3 @@ func TeardownDevEnvironment(t *testing.T) {
})
fmt.Println("::endgroup::")
}

func GetCurrentCommitHash(t *testing.T) string {
return shell.RunCommandAndGetOutput(t, shell.Command{
Command: "git",
Args: []string{"rev-parse", "HEAD"},
WorkingDir: "./",
})
}

0 comments on commit 38922e1

Please sign in to comment.