Skip to content

Commit

Permalink
fix(ci): github container build & releasing
Browse files Browse the repository at this point in the history
Co-authored-by: kuhball <[email protected]>

tests(config): set config path environment variable

fix(ci): trying to get github workflows to work

fix(releasing): token
  • Loading branch information
rwxd committed Oct 18, 2023
1 parent 2b3454f commit ec12894
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 0 deletions.
94 changes: 94 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
---
on:
push:
branches:
- "*"
tags:
- "v*.*.*"

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Setup
run: make setup

- name: Run tests
run: make unit
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Setup
run: make setup

- name: Run pre-commit
run: make pre-commit-all
env:
SKIP: "no-commit-to-branch"
container:
runs-on: ubuntu-latest
needs:
- test
- pre-commit
steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/[email protected]
with:
# list of Docker images to use as base name for tags
images: |
ghcr.io/akquinet/powerdns-api-proxy
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Login to GHCR
if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags') || github.ref == 'refs/heads/main')
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push master Docker image
uses: docker/[email protected]
with:
context: .
push: ${{ github.event_name == 'push' && (startsWith(github.ref, 'refs/tags') || github.ref == 'refs/heads/main') }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

semantic-release:
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs:
- container
steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: false

- name: Semantic Release
uses: cycjimmy/semantic-release-action@v3
env:
GITHUB_TOKEN: "${{ secrets.GH_TOKEN }}"
3 changes: 3 additions & 0 deletions tests/unit/config_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from copy import deepcopy

import pytest
Expand Down Expand Up @@ -28,6 +29,8 @@
ZoneNotAllowedException,
)

os.environ['PROXY_CONFIG_PATH'] = './config-example.yml'

dummy_proxy_zone = ProxyConfigZone(name='test.example.com.')
dummy_proxy_environment_token = 'lashflkashlfgkashglashglashgl'
dummy_proxy_environment_token_sha512 = '127aab81f4caab9c00e72f26e4c5c4b20146201a1548a787494d999febf1b9422c1711932117f38d9be9efe46f78aa72d8f6a391101bedd6e200014f6738450d' # noqa: E501
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/proxy_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from typing import Generator
from unittest.mock import AsyncMock, patch

Expand Down Expand Up @@ -37,6 +38,8 @@
environments=[dummy_proxy_environment, dummy_proxy_environment2],
)

os.environ['PROXY_CONFIG_PATH'] = './config-example.yml'


@pytest.fixture()
def fixture_patch_dummy_config() -> Generator[None, None, None]:
Expand Down

0 comments on commit ec12894

Please sign in to comment.