-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add infrastructure files and CI (#14)
- Loading branch information
Showing
19 changed files
with
3,273 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.makim.yaml | ||
docs/changelog.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
overrides: | ||
- files: "*.md" | ||
options: | ||
parser: remark | ||
proseWrap: always | ||
printWidth: 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.