Skip to content

Commit

Permalink
refactor: major refactor (#40)
Browse files Browse the repository at this point in the history
* refactor: improve CI/CD automation
* feat: adopt [conventional commits](https://www.conventionalcommits.org/en/v1.0.0)
* feat: use github actions instead of gitlab ci
* docs: migrate documentation site

Release-As: 0.8.0
  • Loading branch information
gavinying authored Jul 10, 2024
1 parent dbe722c commit e54fe8f
Show file tree
Hide file tree
Showing 41 changed files with 1,098 additions and 1,289 deletions.
51 changes: 51 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# EditorConfig is awesome: https://EditorConfig.org

root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
end_of_line = lf
trim_trailing_whitespace = true
# insert_final_newline = true
max_line_length = 80

[*.md]
indent_style = space
indent_size = 4
max_line_length = 0
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_style = space
indent_size = 2

[*.json]
indent_style = space
indent_size = 2
insert_final_newline = false

[COMMIT_EDITMSG]
max_line_length = 0

[{Makefile, makefile, GNUmakefile, Makefile.*}]
indent_style = tab
indent_size = 4

[*.sh]
indent_style = space
indent_size = 4

[*.{ps1,psm1,psd1}]
indent_style = space
indent_size = 4

# Black/Ruff has its own set of formatting rules and defaults, which will re-format the code after .editorconfig is applied
[*.py]
indent_size = 4
max_line_length = 88

[*.{tf,tfvars,hcl}]
indent_style = space
indent_size = 2
4 changes: 0 additions & 4 deletions .flake8

This file was deleted.

47 changes: 47 additions & 0 deletions .github/actions/setup-env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: "setup-env"
description: "Composite action to setup the Python and poetry environment, and install Pandoc."

inputs:
python-version:
required: false
description: "The python version to use"
default: "3.12"

runs:
using: "composite"
steps:
- name: Set up python
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}

- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-in-project: true

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ inputs.python-version }}-${{ hashFiles('poetry.lock') }}

- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction
shell: bash

- name: Load cached Pandoc
id: cached-pandoc
uses: actions/cache@v4
with:
path: /usr/local/bin/pandoc
key: pandoc-${{ runner.os }}-${{ hashFiles('.tool-versions') }}

- name: Install Pandoc
if: steps.cached-pandoc.outputs.cache-hit != 'true'
run: |
sudo apt-get update
sudo apt-get install -y pandoc
shell: bash
64 changes: 64 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: main

on:
push:
branches: [main, master]
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

jobs:
quality-check:
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v4

- name: Set up the environment
uses: ./.github/actions/setup-env

- name: Run checks
run: make check

tox:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
fail-fast: false
steps:
- name: Check out
uses: actions/checkout@v4

- name: Set up python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
uses: snok/install-poetry@v1

- name: Load cached venv
uses: actions/cache@v4
with:
path: .tox
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}

- name: Install tox
run: |
python -m pip install --upgrade pip
python -m pip install tox tox-gh-actions
- name: Test with tox
run: tox

docs:
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v4

- name: Set up the environment
uses: ./.github/actions/setup-env

- name: Build documentation
run: make docs
23 changes: 23 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: release-please

on:
push:
branches: [main, master]

permissions:
contents: write
pull-requests: write

jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.TM_INFRA_ROBOT_APP_ID }}
private-key: ${{ secrets.TM_INFRA_ROBOT_PRIVATE_KEY }}
- uses: googleapis/release-please-action@v4
with:
token: ${{ steps.app-token.outputs.token }}
release-type: python
Loading

0 comments on commit e54fe8f

Please sign in to comment.