Skip to content

Commit

Permalink
switch from hub.docker.com to ghcr.io
Browse files Browse the repository at this point in the history
This bundles a couple of changes. Before this CL we tested the
windows client within a docker container. As we stopped supporting
docker on windows quiet a while back it's better to deprecate this
method on moving contrainer registries. This required an overhaul
of the underlying test setup. As a benefit tests are speed up
quiet a lot.

Signed-off-by: Tobias Kohlbau <t.kohlbau@myopenfactory.com>
  • Loading branch information
tobiaskohlbau committed Mar 16, 2023
1 parent a2b2d6b commit caf3059
Show file tree
Hide file tree
Showing 12 changed files with 141 additions and 288 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: CI

on:
pull_request:
push:
branches:
- main

jobs:
tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, windows-2019]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'
- name: Unit Tests
run: go test -v ./...

- name: Build release
uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: build --snapshot --single-target

- name: E2E Tests Linux
if: runner.os == 'Linux'
working-directory: ./test
run: |
export CONFIG_DIR="/tmp/myof/config"
mkdir -p $CONFIG_DIR
echo -n ${CERTIFICATE} | base64 --decode > $CONFIG_DIR/certificate.pem
echo -n ${CONFIG} | base64 --decode > $CONFIG_DIR/config.properties
mkdir -p /tmp/myof/logs
mkdir -p /tmp/myof/inbound
mkdir -p /tmp/myof/outbound
mkdir -p /tmp/myof/success
mkdir -p /tmp/myof/error
mkdir -p /tmp/myof/attachment
../dist/myof-client_linux_amd64_v1/myof-client --config $CONFIG_DIR/config.properties &
go run main.go
env:
CONFIG: ${{ secrets.LINUX_CONFIG }}
CERTIFICATE: ${{ secrets.CLIENT_CERTIFICATE }}

- name: E2E Tests Windows
shell: bash
if: runner.os == 'Windows'
working-directory: ./test
run: |
export CONFIG_DIR="C:/myof/config"
mkdir -p $CONFIG_DIR
echo -n ${CERTIFICATE} | base64 --decode > $CONFIG_DIR/certificate.pem
echo -n ${CONFIG} | base64 --decode > $CONFIG_DIR/config.properties
mkdir -p "C:/myof/logs"
mkdir -p "C:/myof/inbound/"
mkdir -p "C:/myof/outbound/"
mkdir -p "C:/myof/success/"
mkdir -p "C:/myof/error/"
mkdir -p "C:/myof/attachment/"
../dist/myof-client_windows_amd64_v1/myof-client.exe --config $CONFIG_DIR/config.properties &
go run main.go
env:
CONFIG: ${{ secrets.WINDOWS_CONFIG }}
CERTIFICATE: ${{ secrets.CLIENT_CERTIFICATE }}
87 changes: 0 additions & 87 deletions .github/workflows/ci.yml

This file was deleted.

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

permissions:
packages: write
contents: write

on:
push:
tags:
- "v*"

jobs:
push:
runs-on: ubuntu-20.04
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-go@v4
with:
go-version-file: "go.mod"
- name: Prepare THIRD_PARTY folder
run: |
go install github.com/google/go-licenses@latest
go-licenses save . --save_path="THIRD_PARTY/"
- name: Prepare sign certificate
run: echo -n ${SIGN_CERTIFICATE} | base64 --decode > $HOME/key.asc
env:
SIGN_CERTIFICATE: ${{ secrets.SIGN_CERTIFICATE }}
- name: Release
uses: goreleaser/goreleaser-action@v1
with:
version: latest
args: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9 changes: 6 additions & 3 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ builds:
- -X github.com/myopenfactory/client/pkg/version.Version={{.Version}} -X github.com/myopenfactory/client/pkg/version.Date={{.Date}} -X github.com/myopenfactory/client/pkg/version.Commit={{.Commit}}
archives:
- name_template: "{{.Binary}}_{{.Os}}_{{.Arch}}"
rlcp: true
format: tar.gz
format_overrides:
- goos: windows
Expand All @@ -30,16 +31,18 @@ archives:
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
name_template: "snapshot"
dockers:
- goos: linux
goarch: amd64
ids:
- myof-client
dockerfile: Dockerfile
image_templates:
- "myopenfactory/client:alpine"
- "myopenfactory/client:latest"
- "ghcr.io/myopenfactory/client:{{ .Version }}"
- "ghcr.io/myopenfactory/client:{{ .Major}}.{{ .Minor }}"
- "ghcr.io/myopenfactory/client:{{ .Major}}"
- "ghcr.io/myopenfactory/client:latest"
extra_files:
- myOpenFactoryCA.crt
- LICENSE
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ COPY myof-client /myof-client
COPY myOpenFactoryCA.crt /usr/local/share/ca-certificates/extra/myOpenFactoryCA.crt
RUN update-ca-certificates

LABEL org.opencontainers.image.source="https://github.com/myopenfactory/client"

ENTRYPOINT ["/myof-client"]
8 changes: 0 additions & 8 deletions Dockerfile.windows

This file was deleted.

18 changes: 0 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
BUILD_COMMIT := $(shell git rev-parse --short HEAD)
BUILD_DATE := $(shell date -Iseconds)
ifeq ($(OS),Windows_NT)
BUILD_OUTPUT_EXTENSION=.exe
COMPOSE_FILE=docker-compose.windows.yml
else
COMPOSE_FILE=docker-compose.yml
endif

build:
CGO_ENABLED=0 go build -o myof-client${BUILD_OUTPUT_EXTENSION} -ldflags "-X github.com/myopenfactory/client/pkg/version.Date=${BUILD_DATE} -X github.com/myopenfactory/client/pkg/version.Commit=${BUILD_COMMIT}"
CGO_ENABLED=0 go build -o ./test/e2e-test${BUILD_OUTPUT_EXTENSION} ./test

generate:
go generate ./...

protogen:
@./protogen.sh

.PHONY: test
test: build
cd test && docker-compose -f ${COMPOSE_FILE} down -v
cd test && docker-compose -f ${COMPOSE_FILE} up --build --force-recreate --abort-on-container-exit --renew-anon-volumes --exit-code-from test
5 changes: 0 additions & 5 deletions test/Dockerfile.windows

This file was deleted.

41 changes: 0 additions & 41 deletions test/docker-compose.windows.yml

This file was deleted.

14 changes: 14 additions & 0 deletions test/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
services:
client:
image: ghcr.io/myopenfactory/client:snapshot
volumes:
- "${CONFIG_DIR}:/myof/config"
- "./logs:/myof/logs"
- "./inbound:/myof/inbound"
- "./outbound:/myof/outbound"
- "./success:/myof/success"
- "./error:/myof/error"
- "./attachment:/myof/attachment"
command:
- --config
- /myof/config/config.properties
41 changes: 0 additions & 41 deletions test/docker-compose.yml

This file was deleted.

0 comments on commit caf3059

Please sign in to comment.