Skip to content

Commit

Permalink
chore: Add infrastructure files and CI (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
xmnlab authored Mar 18, 2024
1 parent d868653 commit 7816f61
Show file tree
Hide file tree
Showing 19 changed files with 3,273 additions and 149 deletions.
138 changes: 138 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
name: main

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
check-branch:
if: ${{ github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
timeout-minutes: 10
concurrency:
group: check-pr-${{ github.ref }}
cancel-in-progress: true

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

- name: Check if the PR's branch is updated
uses: osl-incubator/gh-check-pr-is-updated@1.0.0
with:
remote_branch: origin/main
pr_sha: ${{ github.event.pull_request.head.sha }}

tests:
needs: check-branch
timeout-minutes: 10
strategy:
matrix:
python_version:
- "3.8.1"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
os:
- "ubuntu"
- "macos"
# - "windows"
runs-on: ${{ matrix.os }}-latest
concurrency:
group: ci-tests-${{ matrix.os }}-${{ matrix.python_version }}-${{ github.ref }}
cancel-in-progress: true

defaults:
run:
shell: bash -l {0}

steps:
- uses: actions/checkout@v3

- name: Install MacOS extra tools and add extra setup
if: ${{ matrix.os == 'macos' }}
run: |
sudo mkdir -p /tmp
sudo chmod 777 /tmp
brew install gnu-sed
echo 'export PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH"' >> ~/.bashrc
echo 'export PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH"' >> ~/.bash_profile
- name: Prepare conda environment (windows)
if: ${{ matrix.os == 'windows' }}
run: |
$env:Path += ";C:\Program Files\Git\usr\bin"
sed -i s/python\ 3\.8\.1/python\ ${{ matrix.python_version }}/ conda/dev.yaml
cat conda/dev.yaml
- name: Prepare conda environment
if: ${{ matrix.os != 'windows' }}
run: |
sed -i s/python\ 3\.8\.1/python\ ${{ matrix.python_version }}/ conda/dev.yaml
cat conda/dev.yaml
- uses: conda-incubator/setup-miniconda@v3
with:
miniconda-version: "latest"
environment-file: conda/dev.yaml
channels: conda-forge,nodefaults
activate-environment: anamnesisai
auto-update-conda: true
conda-solver: libmamba

- name: Install dependencies
run: poetry install

- name: Run unit tests
run: makim tests.unittest

- name: Test jupyter notebooks
run: makim tests.notebooks

linter-and-docs:
needs: check-branch
runs-on: ubuntu-latest
timeout-minutes: 10

defaults:
run:
shell: bash -l {0}

concurrency:
group: ci-linter-docs-${{ matrix.os }}-${{ matrix.python_version }}-${{ github.ref }}
cancel-in-progress: true

steps:
- uses: actions/checkout@v3

- uses: conda-incubator/setup-miniconda@v3
with:
miniconda-version: "latest"
environment-file: conda/dev.yaml
channels: conda-forge,nodefaults
activate-environment: anamnesisai
auto-update-conda: true
conda-solver: libmamba

- name: Install dependencies
run: |
poetry config virtualenvs.create false
poetry install
- name: Test documentation generation
run: makim docs.build

- name: Run style checks
if: success() || failure()
run: |
pre-commit install
makim tests.linter
- name: Setup tmate session
if: "${{ failure() && (contains(github.event.pull_request.labels.*.name, 'ci:enable-debugging')) }}"
uses: mxschmitt/action-tmate@v3
86 changes: 86 additions & 0 deletions .makim.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
version: 1.0
groups:
clean:
targets:
tmp:
help: remove build artifacts, compiled files, and cache
shell: bash
run: |
find . -name '*.egg-info' -exec rm -rf {} +
find . -name '*.egg' -exec rm -f {} +
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '__pycache__' -exec rm -rf {} +
find . -name '*~' -exec rm -f {} +
rm -rf build/
rm -rf dist/
rm -rf .eggs/
rm -f .coverage
rm -rf htmlcov/
rm -rf .pytest_cache
tests:
targets:
linter:
help: run linter tools
run: |
pre-commit install
pre-commit run --all-files
unittest:
help: run tests
args:
path:
help: Specify the location of the tests
type: string
default: ""
params:
help: Specify parameters to be used for tests
type: string
default: "-vv"
run: pytest {{ args.path }} {{ args.params }}

notebooks:
help: test jupyter notebooks
run: pytest -vv --nbmake docs/tutorials

ci:
help: run the sames tests executed on CI
dependencies:
- target: tests.unittest
- target: tests.notebooks
- target: tests.linter

docs:
targets:
build:
help: build documentation
run: mkdocs build --config-file mkdocs.yaml

preview:
help: preview documentation page locally
run: mkdocs serve --watch docs --config-file mkdocs.yaml

release:
vars:
app: |
npx --yes \
-p semantic-release \
-p conventional-changelog-conventionalcommits \
-p "@semantic-release/commit-analyzer" \
-p "@semantic-release/release-notes-generator" \
-p "@semantic-release/changelog" \
-p "@semantic-release/exec" \
-p "@semantic-release/github" \
-p "@semantic-release/git" \
-p "semantic-release-replace-plugin" \
semantic-release
targets:
ci:
help: run semantic release on CI
run: {{ vars.app }} --ci

dry:
help: run semantic release in dry-run mode
run: {{ vars.app }} --dry-run
82 changes: 82 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
default_stages:
- commit
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: end-of-file-fixer

- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.0.2"
hooks:
- id: prettier

- repo: local
hooks:
- id: ruff-format
name: ruff-format
entry: ruff format
exclude: |
(?x)(
docs
)
language: system
pass_filenames: true
types:
- python

- id: ruff-linter
name: ruff-linter
entry: ruff check
language: system
exclude: "docs/"
pass_filenames: true
types:
- python

- id: mypy
name: mypy
entry: mypy .
language: system
pass_filenames: false

- id: shellcheck
name: shellcheck
entry: shellcheck
language: system
types_or:
- sh
- shell
- ash
- bash
- bats
- dash
- ksh

- id: bandit
name: bandit
entry: bandit
language: system
args: ["--configfile", "pyproject.toml", "-iii", "-lll"]
pass_filenames: true
types:
- python

- id: vulture
name: vulture
entry: vulture --min-confidence 80
language: system
files: "src/astx"
description: Find unused Python code.
pass_filenames: true
types:
- python

- id: mccabe
name: mccabe
entry: python -m mccabe --min 10
language: system
files: "src/astx"
pass_filenames: true
types:
- python
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.makim.yaml
docs/changelog.md
6 changes: 6 additions & 0 deletions .prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
overrides:
- files: "*.md"
options:
parser: remark
proseWrap: always
printWidth: 80
29 changes: 14 additions & 15 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ diverse, inclusive, and healthy community.
Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions, viewpoints, and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the overall
- Focusing on what is best not just for us as individuals, but for the overall
community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or advances of
- The use of sexualized language or imagery, and sexual attention or advances of
any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email address,
- Trolling, insulting or derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or email address,
without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities
Expand All @@ -59,9 +59,8 @@ representative at an online or offline event.
## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
[INSERT CONTACT METHOD].
All complaints will be reviewed and investigated promptly and fairly.
reported to the community leaders responsible for enforcement at [INSERT CONTACT
METHOD]. All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.
Expand Down Expand Up @@ -118,8 +117,8 @@ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.1, available at
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].

Community Impact Guidelines were inspired by
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder][Mozilla CoC].

For answers to common questions about this code of conduct, see the FAQ at
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
Expand Down
Loading

0 comments on commit 7816f61

Please sign in to comment.