Skip to content

Commit e216557

Browse files
committed
feat(CI): Improve CI
1 parent fcc7a07 commit e216557

File tree

8 files changed

+140
-44
lines changed

8 files changed

+140
-44
lines changed

.github/workflows/main.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
name: Main
6+
jobs:
7+
oas:
8+
name: 'OAS Readme'
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
- uses: readmeio/github-readme-sync@v2
13+
with:
14+
readme-oas-key: ${{ secrets.README_OAS_KEY }}
15+
oas-file-path: './spec/http.yml'
16+
api-version: 'v1.0.0'
17+
terraform:
18+
name: 'Terraform'
19+
runs-on: ubuntu-latest
20+
env:
21+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
22+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
23+
steps:
24+
- uses: actions/setup-go@v2
25+
with:
26+
go-version: '1.16'
27+
- uses: actions/checkout@v2
28+
- name: Configure git for private modules
29+
env:
30+
TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
31+
run: git config --global url."https://altitude:${TOKEN}@github.com".insteadOf "https://github.com"
32+
- uses: actions/cache@v2
33+
with:
34+
path: |
35+
~/.cache/go-build
36+
~/go/pkg/mod
37+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
38+
restore-keys: |
39+
${{ runner.os }}-go-
40+
- name: get deps
41+
run: go get
42+
- name: Run GoReleaser
43+
uses: goreleaser/goreleaser-action@v2
44+
with:
45+
version: latest
46+
args: build --parallelism 4 --rm-dist --skip-validate
47+
env:
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
- name: Configure AWS credentials
50+
uses: aws-actions/configure-aws-credentials@v1
51+
with:
52+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
53+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
54+
aws-region: eu-west-1
55+
- name: Login to Amazon ECR
56+
id: login-ecr
57+
uses: aws-actions/amazon-ecr-login@v1
58+
- name: Build, tag, and push image to Amazon ECR
59+
env:
60+
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
61+
ECR_REPOSITORY: numary-preprod-ecr
62+
IMAGE_TAG: ${{ github.sha }}
63+
run: |
64+
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
65+
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
66+

.github/workflows/oas-readme.yml

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

.github/workflows/pr_open.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Pull Request - Open
2+
on:
3+
pull_request:
4+
types: [opened, reopened, synchronize]
5+
jobs:
6+
Test:
7+
name: 'Test'
8+
runs-on: ubuntu-latest
9+
env:
10+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
11+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
12+
steps:
13+
- uses: actions/setup-go@v2
14+
with:
15+
go-version: '1.16'
16+
- uses: actions/checkout@v2
17+
- name: Configure git for private modules
18+
env:
19+
TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
20+
run: git config --global url."https://altitude:${TOKEN}@github.com".insteadOf "https://github.com"
21+
- uses: actions/cache@v2
22+
with:
23+
path: |
24+
~/.cache/go-build
25+
~/go/pkg/mod
26+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
27+
restore-keys: |
28+
${{ runner.os }}-go-
29+
- name: get deps
30+
run: go get
31+
- name: run tests
32+
run: go test -v -coverpkg=./... -coverprofile=coverage.out ./...
33+
Lint:
34+
name: 'Lint'
35+
runs-on: ubuntu-latest
36+
env:
37+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
38+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
39+
steps:
40+
- uses: actions/setup-go@v2
41+
with:
42+
go-version: '1.16'
43+
- uses: actions/checkout@v2
44+
- name: Configure git for private modules
45+
env:
46+
TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
47+
run: git config --global url."https://altitude:${TOKEN}@github.com".insteadOf "https://github.com"
48+
- uses: actions/cache@v2
49+
with:
50+
path: |
51+
~/.cache/go-build
52+
~/go/pkg/mod
53+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
54+
restore-keys: |
55+
${{ runner.os }}-go-
56+
- name: get deps
57+
run: go get
58+
- name: run vet
59+
run: go vet .

.github/workflows/release.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ jobs:
2424
env:
2525
TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
2626
run: git config --global url."https://altitude:${TOKEN}@github.com".insteadOf "https://github.com"
27+
- uses: actions/cache@v2
28+
with:
29+
path: |
30+
~/.cache/go-build
31+
~/go/pkg/mod
32+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
33+
restore-keys: |
34+
${{ runner.os }}-go-
2735
- name: get deps
2836
run: go get
2937
- name: Run GoReleaser

.github/workflows/test.yml

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

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
numary
2-
coverage.out
2+
coverage.out
3+
/dist/

.goreleaser.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
before:
22
hooks:
3-
- go build
3+
- go build -o numary
44
builds:
55
- env:
6-
- CGO_ENABLED=0
6+
- CGO_ENABLED=1
77
goos:
88
- linux
9-
main: ./main
9+
binary: numary
1010
archives:
1111
- replacements:
1212
linux: Linux

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM alpine:latest
22

3-
ADD numary /usr/local/bin/numary
3+
ADD dist/ledger_linux_amd64/numary /usr/local/bin/numary
44

55
EXPOSE 3068
66

7-
CMD ["numary", "server", "start"]
7+
CMD ["numary", "server", "start"]

0 commit comments

Comments
 (0)