Skip to content

Commit d315efe

Browse files
committed
test workflow
1 parent 73c6396 commit d315efe

File tree

5 files changed

+148
-209
lines changed

5 files changed

+148
-209
lines changed

.github/workflows/nonprod.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
on:
2+
pull_request:
3+
types:
4+
- opened
5+
- synchronize
6+
- reopened
7+
branches:
8+
- master
9+
push:
10+
branches:
11+
- master
12+
13+
jobs:
14+
pipeline:
15+
uses: ./.github/workflows/pipeline.yaml
16+
with:
17+
environment: nonprod
18+
19+
secrets:
20+
AWS_DEFAULT_REGION: us-east-1
21+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_DCE_API_ADMIN_NONPROD_ACCESS_KEY_ID }}
22+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_DCE_API_ADMIN_NONPROD_SECRET_ACCESS_KEY }}
Lines changed: 126 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,63 @@
1-
name: Deploy
1+
name: DCE deploy to environment
22

33
on:
4-
workflow_dispatch:
5-
workflow_run:
6-
workflows: [TestAndBuild]
7-
types:
8-
- completed
4+
workflow_call:
5+
inputs:
6+
environment:
7+
required: true
8+
type: string
9+
description: 'The environment to deploy to'
10+
default: 'nonprod'
11+
env:
12+
GO_VERSION: 1.21.6
13+
TERRAFORM_VERSION: 1.7.4
14+
915

1016
jobs:
17+
TestAndBuild:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v2
22+
23+
- name: Setup Python
24+
uses: actions/setup-python@v2
25+
with:
26+
python-version: "3.x"
27+
28+
- name: Install Terraform
29+
uses: hashicorp/setup-terraform@v1
30+
with:
31+
terraform_version: ${{ env.TERRAFORM_VERSION }}
32+
33+
- name: Setup Go
34+
uses: actions/setup-go@v2
35+
with:
36+
go-version: ${{ env.GO_VERSION }}
37+
38+
- name: Set up Golang CI Tools
39+
run: ./scripts/install_ci.sh
40+
41+
- name: Checkout repository
42+
uses: actions/checkout@v2
43+
44+
- name: Build Go executables
45+
run: make build
46+
47+
- name: Publish build artifacts (bin)
48+
uses: actions/upload-artifact@v4
49+
with:
50+
name: bin
51+
path: bin
52+
53+
- name: Publish build artifacts (deploy_scripts)
54+
uses: actions/upload-artifact@v4
55+
with:
56+
name: deploy_scripts
57+
path: scripts
58+
1159
Deploy:
12-
if: ${{ github.event.workflow_run.conclusion == 'success' }}
60+
needs: [TestAndBuild]
1361
runs-on: ubuntu-latest
1462
environment: "nonprod"
1563
steps:
@@ -160,7 +208,7 @@ jobs:
160208
echo "Running build script"
161209
./scripts/build.sh
162210
163-
# Deploy Application Code to AWS -- > TODO: ARTIFACTS_BUCKET_NAME and NAMESPACE values are hardcoded as -raw flag or jq are throwing errors
211+
# Deploy Application Code to AWS -- > TODO ARTIFACTS_BUCKET_NAME and NAMESPACE values are hardcoded as -raw flag or jq are throwing errors
164212
- name: Deploy Application Code
165213
run: |
166214
@@ -176,7 +224,7 @@ jobs:
176224
github-pr-513 \
177225
000879607493-dce-artifacts-github-pr-513
178226
179-
# Functional Tests --> TODO: need to fix the Functional Tests failures
227+
# Functional Tests --> TODO need to fix the test failures
180228
# - name: Functional Tests
181229
# run: |
182230
# set -euxo pipefail
@@ -185,7 +233,7 @@ jobs:
185233
# go get github.com/jstemmer/go-junit-report
186234
# go test -v ./tests/... -test.timeout 50m 2>&1 | tee >(go-junit-report > junit-report/functional.xml)
187235

188-
# Publish junit test results (for unit and functional tests) -- > TODO need to fix the Functional Tests failures
236+
# Publish junit test results (for unit and functional tests) -- > TODO need to fix the test failures
189237

190238
# - name: Publish Test Results
191239
# if: always()
@@ -326,3 +374,71 @@ jobs:
326374
./dce --config=./dce.yml leases end \
327375
-p ${namespace} \
328376
-a ${account_id}
377+
378+
Release:
379+
needs: [Deploy]
380+
runs-on: ubuntu-latest
381+
steps:
382+
- name: Checkout repository
383+
uses: actions/checkout@v2
384+
385+
- name: Fetch all tags
386+
run: git fetch --tags
387+
388+
- name: Download bin artifact
389+
uses: actions/download-artifact@v4
390+
with:
391+
name: bin
392+
path: ${{ github.workspace }}/bin
393+
394+
- name: Download deploy_scripts artifact
395+
uses: actions/download-artifact@v4
396+
with:
397+
name: deploy_scripts
398+
path: ${{ github.workspace }}/deploy_scripts
399+
400+
- name: Get latest version tag
401+
id: get_latest_tag
402+
run: |
403+
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`)
404+
echo "::set-output name=latest_tag::$latest_tag"
405+
406+
- name: Increment version tag
407+
id: increment_tag
408+
run: |
409+
latest_tag=${{ steps.get_latest_tag.outputs.latest_tag }}
410+
if [[ $latest_tag =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
411+
major=${BASH_REMATCH[1]}
412+
minor=${BASH_REMATCH[2]}
413+
patch=${BASH_REMATCH[3]}
414+
new_tag="v$major.$minor.$((patch + 1))"
415+
else
416+
new_tag="v0.0.1"
417+
fi
418+
echo "::set-output name=new_tag::$new_tag"
419+
420+
- name: Determine if prerelease
421+
id: prerelease_check
422+
run: |
423+
if [ "${{ github.ref }}" == "refs/heads/master" ]; then
424+
echo "::set-output name=prerelease::false"
425+
else
426+
echo "::set-output name=prerelease::true"
427+
fi
428+
429+
- name: Create GitHub Release
430+
if: github.event_name != 'pull_request'
431+
uses: actions/create-release@v1
432+
env:
433+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
434+
with:
435+
tag_name: ${{ steps.increment_tag.outputs.new_tag }}
436+
release_name: Release ${{ steps.increment_tag.outputs.new_tag }}
437+
draft: false
438+
prerelease: ${{ steps.prerelease_check.outputs.prerelease }}
439+
files: |
440+
${{ github.workspace }}/bin/build_artifacts.zip
441+
${{ github.workspace }}/bin/terraform_artifacts.zip
442+
${{ github.workspace }}/deploy_scripts/deploy.sh
443+
${{ github.workspace }}/deploy_scripts/restore_db.sh
444+

.github/workflows/prerelease.yml

Lines changed: 0 additions & 50 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 0 additions & 54 deletions
This file was deleted.

.github/workflows/test-and-build.yml

Lines changed: 0 additions & 95 deletions
This file was deleted.

0 commit comments

Comments
 (0)