Skip to content

Commit

Permalink
add github workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
shanedabes committed May 14, 2022
1 parent e399af7 commit c5ad27c
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/renovate.json
@@ -0,0 +1,17 @@
{
"dependencyDashboard": true,
"enabled": true,
"packageRules": [
{
"matchDatasources": [ "github-tags" ],
"automerge": true,
"automergeType": "branch",
"groupName": "github-tags"
},
{
"matchDatasources": [ "go" ],
"automerge": true
}
],
"timezone": "Europe/London"
}
3 changes: 3 additions & 0 deletions .github/workflows/mosquitto_config/mosquitto.conf
@@ -0,0 +1,3 @@
listener 1883
protocol mqtt
allow_anonymous true
115 changes: 115 additions & 0 deletions .github/workflows/release.yaml
@@ -0,0 +1,115 @@
---
name: Release

on:
workflow_dispatch:
push:
branches:
- main
paths:
- '*.go'
- go.mod
- go.sum
pull_request:
paths:
- '*.go'
- go.mod
- go.sum
- .github/workflows/*.yaml

jobs:
gotest:
name: Go test
runs-on: ubuntu-20.04

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18

- name: Test
run: go test -v ./...

e2e:
name: End to end test
runs-on: ubuntu-20.04

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18

- name: Install mosquitto
run: sudo apt-get install -y mosquitto mosquitto-clients

- name: Run mosquitto
run: |
mosquitto -c ${{ github.workspace }}/.github/workflows/mosquitto_config/mosquitto.conf &
sleep 2
- name: Run module
run: |
go run . &
sleep 5
env:
GOWON_GOTEMPLATE_CONFIG: "${{ github.workspace }}/config-e2e.yaml"

- name: Run end to end testing
run: ./e2e.sh

build:
name: Build
runs-on: ubuntu-20.04
needs:
- gotest
- e2e
if: "!contains(github.event.head_commit.message, '[ci-skip]')"

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0.9.13
with:
versionSpec: '5.x'

- name: GitVersion
id: gitversion
uses: gittools/actions/gitversion/execute@v0.9.13

- name: Prepare
id: prep
run: |
if [ "${{github.event_name}}" == "pull_request" ]; then
echo ::set-output name=PUSH::false
else
echo ::set-output name=PUSH::true
fi
echo ::set-output name=GITVERSIONF::${GITVERSION_FULLSEMVER/+/-}
- name: Setup ko
uses: imjasonh/setup-ko@v0.4

- name: Build local image
run: >
ko build --bare --platform linux/amd64,linux/arm64
--sbom none --tags latest,${{ steps.prep.outputs.GITVERSIONF }} --push=false .
if: ${{ steps.prep.outputs.PUSH == 'false' }}

- name: Build and push image
run: >
ko build --bare --platform linux/amd64,linux/arm64
--sbom none --tags latest,${{ steps.prep.outputs.GITVERSIONF }} .
if: ${{ steps.prep.outputs.PUSH == 'true' }}

0 comments on commit c5ad27c

Please sign in to comment.