Skip to content

Commit

Permalink
🛠️ ci: setup tests in GitHub (#124)
Browse files Browse the repository at this point in the history
* ci: fix warning deprecated save state https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

* ci: run tests

* fix: test fail in github action

* ci: fix actons

* ci: move old branch master to main
  • Loading branch information
ludusrusso authored Feb 18, 2023
1 parent 184de64 commit 5de8d7b
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 21 deletions.
16 changes: 8 additions & 8 deletions .github/actions/build-docker/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ runs:
steps:
- name: Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/${{ github.repository }}/${{ inputs.docker-target }}
tag-sha: true
tag-semver: |
{{version}}
{{major}}.{{minor}}
tag-custom: |
${{inputs.branch}}-${{inputs.sha}}-${{ inputs.ts }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=sha
type=raw,value=${{inputs.branch}}-${{inputs.sha}}-${{ inputs.ts }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
push: ${{ github.ref == 'refs/heads/main' }}
network: host
Expand Down
34 changes: 25 additions & 9 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,48 @@ name: CI
on:
push:
branches:
- '**'
- 'main'
tags:
- 'v*'
pull_request:
branches: ['*']
branches:
- 'main'

jobs:
test:
runs-on: ubuntu-20.04
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.19
- name: Build
run: go build -v ./...
- name: Test
run: go test -v ./...
build:
runs-on: ubuntu-20.04
needs: test
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: actions/checkout@v3
- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get Vars
id: get_vars
run: |
echo "::set-output name=ts::$(date +%s)"
echo "::set-output name=sha::$(git rev-parse --short HEAD)"
echo "::set-output name=branch::$(git rev-parse --abbrev-ref HEAD)"
echo "ts=$(date +%s)" >> $GITHUB_OUTPUT
echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "branch=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_OUTPUT
- name: Build Kannon
uses: ./.github/actions/build-docker
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/golang.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ on:
tags:
- v*
branches:
- master
- main
pull_request:
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Release Drafter
on:
push:
branches:
- master
- main
pull_request:
types: [opened, reopened, synchronize]

Expand Down
3 changes: 2 additions & 1 deletion pkg/api/mailapi/mailer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestInsertMail(t *testing.T) {

ctx := getDomainCtx(d)

schedTime := time.Now().Add(10 * time.Minute)
schedTime := time.Now().Add(10 * time.Minute).Truncate(1 * time.Second)

res, err := ts.SendHTML(ctx, &mailerv1.SendHTMLReq{
Sender: &types.Sender{
Expand All @@ -38,6 +38,7 @@ func TestInsertMail(t *testing.T) {
Html: "Hello {{ name }}",
ScheduledTime: timestamppb.New(schedTime),
})

assert.Nil(t, err)
assert.NotEmpty(t, res.MessageId)
assert.NotEmpty(t, res.TemplateId)
Expand Down

0 comments on commit 5de8d7b

Please sign in to comment.