Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 49 additions & 31 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,58 @@ name: CI

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

jobs:
test:
name: Run tests
ci:
name: Run tests and handle coverage
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.10.7
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest pytest-cov pytest-shell
python setup.py install
- name: Install Python Poetry
run: |
python -m pip install --upgrade pip
pip install poetry
poetry install --with dev
- name: Generate coverage report
run: rm -rf zoutput && poetry run pytest --cov=causalspyne tests/ --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
flags: unittests
env_vars: OS,PYTHON
fail_ci_if_error: true
env:
CODECOV_TOKEN: 02ecb3ac-b7ce-4ea4-90a2-961c3d1a1030
- name: Check out repository
uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true

- name: Install dependencies (including dev)
run: uv sync --dev

- name: Run tests and generate coverage reports
run: |
rm -rf htmlcov coverage.xml
uv run pytest \
--cov=causalspyne \
--cov-report=xml:coverage.xml \
--cov-report=html:htmlcov

- name: Deploy coverage preview
if: github.event_name == 'pull_request'
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: htmlcov
clean: false
token: ${{ secrets.GITHUB_TOKEN }}
target-folder: pr-${{ github.event.number }}

- name: "View coverage report: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pr-${{ github.event.number }}/index.html"
if: github.event_name == 'pull_request'
run: echo "Preview deployed at https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pr-${{ github.event.number }}/index.html"

- name: Generate coverage badge
if: github.ref == 'refs/heads/main'
run: |
python -m pip install genbadge[coverage]
genbadge coverage -i - < coverage.xml > coverage-badge.svg

- name: Deploy production coverage
if: github.ref == 'refs/heads/main'
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: htmlcov
clean: true
token: ${{ secrets.GITHUB_TOKEN }}
82 changes: 0 additions & 82 deletions .github/workflows/python-package.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.pypi_token
155 changes: 155 additions & 0 deletions devenv.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
{
"nodes": {
"devenv": {
"locked": {
"dir": "src/modules",
"lastModified": 1760560333,
"owner": "cachix",
"repo": "devenv",
"rev": "0a4043938f540027e562c5a0feebbe6be872c3ea",
"type": "github"
},
"original": {
"dir": "src/modules",
"owner": "cachix",
"repo": "devenv",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1747046372,
"owner": "edolstra",
"repo": "flake-compat",
"rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-compat_2": {
"flake": false,
"locked": {
"lastModified": 1747046372,
"owner": "edolstra",
"repo": "flake-compat",
"rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"git-hooks": {
"inputs": {
"flake-compat": "flake-compat",
"gitignore": "gitignore",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1760392170,
"owner": "cachix",
"repo": "git-hooks.nix",
"rev": "46d55f0aeb1d567a78223e69729734f3dca25a85",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "git-hooks.nix",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"git-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709087332,
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1758532697,
"owner": "cachix",
"repo": "devenv-nixpkgs",
"rev": "207a4cb0e1253c7658c6736becc6eb9cace1f25f",
"type": "github"
},
"original": {
"owner": "cachix",
"ref": "rolling",
"repo": "devenv-nixpkgs",
"type": "github"
}
},
"nixpkgs-python": {
"inputs": {
"flake-compat": "flake-compat_2",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1760045435,
"owner": "cachix",
"repo": "nixpkgs-python",
"rev": "5dd936b1ce299f6d230774a88b1052e47f71ab91",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "nixpkgs-python",
"type": "github"
}
},
"nixpkgs-unstable": {
"locked": {
"lastModified": 1760533177,
"owner": "nixos",
"repo": "nixpkgs",
"rev": "35f590344ff791e6b1d6d6b8f3523467c9217caf",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"devenv": "devenv",
"git-hooks": "git-hooks",
"nixpkgs": "nixpkgs",
"nixpkgs-python": "nixpkgs-python",
"nixpkgs-unstable": "nixpkgs-unstable",
"pre-commit-hooks": [
"git-hooks"
]
}
}
},
"root": "root",
"version": 7
}
25 changes: 25 additions & 0 deletions devenv.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{ pkgs, lib, config, inputs, ... }:
let
pkgs-unstable = import inputs.nixpkgs-unstable { system = pkgs.stdenv.system; };
in
{
# https://devenv.sh/packages/
packages = [ pkgs.git ];

# https://devenv.sh/languages/
languages.python = {
enable = true;
version = "3.12";
uv = {
enable = true;
package = pkgs-unstable.uv;
sync.enable = true;
};
venv.enable = true;
};

enterShell = ''
'';

# See full reference at https://devenv.sh/reference/options/
}
22 changes: 22 additions & 0 deletions devenv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# yaml-language-server: $schema=https://devenv.sh/devenv.schema.json
inputs:
nixpkgs:
url: github:cachix/devenv-nixpkgs/rolling
nixpkgs-unstable:
url: github:nixos/nixpkgs/nixpkgs-unstable
nixpkgs-python:
url: github:cachix/nixpkgs-python
inputs:
nixpkgs:
follows: nixpkgs

# If you're using non-OSS software, you can set allowUnfree to true.
# allowUnfree: true

# If you're willing to use a package that's vulnerable
# permittedInsecurePackages:
# - "openssl-1.1.1w"

# If you have more than one devenv you can merge them
#imports:
# - ./backend
6 changes: 6 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
def main():
print("Hello from causalspyne!")


if __name__ == "__main__":
main()
Loading