Skip to content

Commit

Permalink
Merge pull request #20 from nlnwa/ci
Browse files Browse the repository at this point in the history
Add test and release workflows for GitHub Actions
  • Loading branch information
maeb authored Aug 20, 2021
2 parents d131b78 + 59d8249 commit 4117f9a
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 5 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Release

on:
push:
tags:
- 'v*'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

permissions:
contents: read
packages: write

jobs:
release:
name: Build and publish docker image
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Setup golang
uses: actions/setup-go@v2
with:
go-version: '^1.15'

- name: Cache go modules
uses: actions/cache@v2
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Extract metadata (tags, labels) and establish version
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
- name: Log in to the container registry (${{ env.REGISTRY }})
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
36 changes: 36 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Unit tests

on:
push:
branches:
- master
pull_request: { }

permissions:
contents: read

jobs:
unit_test:
name: Golang unit tests
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- uses: actions/setup-go@v2
with:
go-version: '^1.15'

- name: Cache go modules
uses: actions/cache@v2
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run tests
run: go test ./...
7 changes: 2 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@ EXPOSE 8181
ENV DNS_SERVER=8.8.8.8 \
CONTENT_WRITER_HOST=veidemann-contentwriter \
CONTENT_WRITER_PORT=8080 \
DB_HOST=localhost \
DB_PORT=28015 \
DB_USER=admin \
DB_PASSWORD=admin \
DB_NAME=veidemann
LOG_WRITER_HOST=veidemann-log-service \
LOG_WRITER_PORT=8080

COPY --from=0 /build/veidemann-dns-resolver /veidemann-dns-resolver
COPY Corefile.docker /Corefile
Expand Down

0 comments on commit 4117f9a

Please sign in to comment.