Skip to content

Commit

Permalink
ci: switch from makefile to taskfile
Browse files Browse the repository at this point in the history
  • Loading branch information
nikaro committed Aug 11, 2024
1 parent 37e2de5 commit f7f25bd
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 61 deletions.
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# EditorConfig is awesome: https://editorconfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 2
insert_final_newline = true

[*.py]
indent_size = 4

[Makefile]
indent_style = tab
3 changes: 1 addition & 2 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
echo Running pre-commit hook

# Run pre-commit, this checks if we changed any files and runs the checks.
# The files are then git-added
FILES=$(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g')
if [ -n "$FILES" ]; then
if ! make lint >/dev/null 2>&1; then
if ! task lint >/dev/null 2>&1; then
echo "Error running make lint - please fix before committing"
echo "if this is a mistake you can skip the checks with 'git commit --no-verify'"
exit 1
Expand Down
13 changes: 8 additions & 5 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
environment: release
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@main
with:
fetch-depth: 0

Expand All @@ -47,13 +47,16 @@ jobs:
skipIfReleaseExists: true
tag: ${{ env.REVISION }}

- name: Setup Rye
if: env.PREVIOUS_REVISION != env.REVISION
uses: nikaro/actions/setup-rye@main
- name: Install tools
run: |
echo "/home/linuxbrew/.linuxbrew/bin" >> "$GITHUB_PATH"
/home/linuxbrew/.linuxbrew/bin/brew install \
go-task \
rye \
- name: Build package
if: env.PREVIOUS_REVISION != env.REVISION
run: make build
run: task build --yes

- name: Publish package to PyPI
if: env.PREVIOUS_REVISION != env.REVISION
Expand Down
24 changes: 18 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
workflow_call:
workflow_dispatch:

env:
TASK_X_REMOTE_TASKFILES: 1

jobs:
lint:
name: Lint
Expand All @@ -16,21 +19,26 @@ jobs:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@main

- name: Install tools
run: |
echo "/home/linuxbrew/.linuxbrew/bin" >> "$GITHUB_PATH"
/home/linuxbrew/.linuxbrew/bin/brew install \
actionlint \
check-jsonschema \
ruff \
fd \
go-task \
jq \
prettier \
rye \
shellcheck \
shfmt \
yamlfmt \
yamllint \
- name: Lint
run: make lint
run: task lint --yes

test:
name: Test
Expand All @@ -39,19 +47,23 @@ jobs:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@main

- name: Install tools
run: |
echo "/home/linuxbrew/.linuxbrew/bin" >> "$GITHUB_PATH"
/home/linuxbrew/.linuxbrew/bin/brew install \
go-task \
rye \
- name: Install dependencies
run: make sync
run: task sync --yes

- name: Test
run: task test --yes

- name: Test
run: make test
run: task build --yes

check:
name: Check
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ wheels/
.venv/
.python-version
.sl/
.task/
48 changes: 0 additions & 48 deletions Makefile

This file was deleted.

83 changes: 83 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
version: '3'

set: [errexit, nounset, pipefail]
shopt: [globstar]

includes:
lint:
taskfile: https://github.com/nikaro/meta/raw/main/taskfiles/lint.yml
internal: true
format:
taskfile: https://github.com/nikaro/meta/raw/main/taskfiles/format.yml
internal: true

tasks:
init:
desc: Initialize repositry
cmds:
- git config core.hooksPath .githooks
- git config commit.template .gitmessage

lock:
desc: Update lockfile
cmd: rye lock --all-features --update-all

sync:
desc: Synchronize virtualenv with lockfile
cmd: rye sync --all-features --no-lock || rye sync --all-features --no-lock --force

lint:
desc: Run linters
cmds:
- task: lint:default
- task: lint:python

lint:python:
desc: Lint Python code
sources:
- ./src/**/*.py
cmds:
- rye fmt --check
- rye lint
- rye run type-check

format:
desc: Run formatters
cmds:
- task: format:default
- task: format:python

format:python:
desc: Format Python code
sources:
- ./src/**/*.py
- ./tests/**/*.py
cmds:
- rye fmt

test:
desc: Run tests
sources:
- ./src/**/*.py
- ./tests/**/*.py
cmd: rye test

build:
desc: Build project
sources:
- ./src/**/*.py
- ./tests/**/*.py
- ./pyproject.toml
- ./requirements.lock
generates:
- ./dist/*.whl
- ./dist/*.tar.gz
cmd: rye build

clean:
desc: Cleanup workspace
cmds:
- rm -rf ./dist/
- rm -rf ./.ruff_cache/
- rm -rf ./.pytest_cache/
- fd --type directory --no-ignore __pycache__ | xargs rm -rf

0 comments on commit f7f25bd

Please sign in to comment.