Skip to content

Commit

Permalink
feat: test and build CI/CD. Code coverage reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
Wil Simpson committed Dec 6, 2024
1 parent 43a9001 commit e614714
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 4 deletions.
7 changes: 7 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### Proposed Changes
- Change 1
- Change 2

### Related Issue(s)


42 changes: 42 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Build Image

on:
workflow_run:
workflows: ["Run Tests"]
types:
- completed

env:
BASE_REGISTRY: ${{ secrets.BASE_REGISTRY }}
REGISTRY: '${{ secrets.BASE_REGISTRY }}/sro'

permissions:
id-token: write
contents: read

jobs:
deploy:
if: |
github.event.workflow_run.conclusion == 'success' && contains('
refs/heads/main
', github.ref)
name: Deploy
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v3
with:
role-to-assume: arn:aws:iam::779965382548:role/SRO_GitHub_Go-Backend_Production
role-session-name: sroawsdeploy
aws-region: us-east-1

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: Build, tag, and push image to registry
id: build-image
run: make docker-push
41 changes: 41 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Run Tests

on:
push:
branches:
- main
- qa
- dev
pull_request:
branches: [ '**' ]

jobs:
test:
runs-on: ubuntu-latest
services:
dind:
image: docker:27-rc-dind-rootless
ports:
- 2375:2375
name: Test
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.23

- name: Build
run: go build -v ./...

- name: Test
run: |
make install-tools
echo "${HOME}/go/bin" >> $GITHUB_PATH
make test
- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ push:

docker-push: docker push

build-image-push: build-image push

.PHONY: clean-protos protos $(PROTO_FILES)

clean-protos:
Expand All @@ -144,11 +142,11 @@ install-tools:

git: git-patch
git-major:
git tag -a v$(shell echo $(MAJOR_VERSION)+1 | bc).0.0
git tag v$(shell echo $(MAJOR_VERSION)+1 | bc).0.0
git push
git push --tags
git-minor:
git tag -a v$(MAJOR_VERSION).$(shell echo $(MINOR_VERSION)+1 | bc).0
git tag v$(MAJOR_VERSION).$(shell echo $(MINOR_VERSION)+1 | bc).0
git push
git push --tags
git-patch:
Expand Down

0 comments on commit e614714

Please sign in to comment.