Skip to content

Commit 242ec1f

Browse files
committed
add CI tests
1 parent ca4a4b3 commit 242ec1f

File tree

3 files changed

+99
-0
lines changed

3 files changed

+99
-0
lines changed

.github/workflows/tests.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# run test suites
2+
3+
name: Tests
4+
on:
5+
- pull_request
6+
- push
7+
- release
8+
- workflow_dispatch
9+
10+
# cancel the current workflow if another commit was pushed on the same PR or reference
11+
# uses the GitHub workflow name to avoid collision with other workflows running on the same PR/reference
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
# see: https://github.com/fkirc/skip-duplicate-actions
18+
skip_duplicate:
19+
continue-on-error: true
20+
runs-on: ubuntu-latest
21+
outputs:
22+
should_skip: ${{ steps.skip_duplicate.outputs.should_skip && ! contains(github.ref, 'refs/tags') && ! contains(github.ref, 'refs/heads/main') }}
23+
steps:
24+
- uses: fkirc/skip-duplicate-actions@master
25+
with:
26+
concurrent_skipping: "same_content_newer"
27+
skip_after_successful_duplicate: "true"
28+
cancel_others: "true"
29+
do_not_skip: '["workflow_dispatch", "schedule", "release"]'
30+
31+
# see: https://github.com/actions/setup-python
32+
tests:
33+
needs: skip_duplicate
34+
if: ${{ needs.skip_duplicate.outputs.should_skip != 'true' }}
35+
runs-on: ${{ matrix.os }}
36+
continue-on-error: ${{ matrix.allow-failure }}
37+
strategy:
38+
matrix:
39+
os: [ubuntu-latest]
40+
python-version: ["3.10", "3.11", "3.12", "3.13"]
41+
test-case: ["test-only"]
42+
steps:
43+
- uses: actions/checkout@v2
44+
with:
45+
fetch-depth: "0"
46+
- name: Setup Python
47+
uses: actions/setup-python@v5
48+
with:
49+
python-version: "${{ matrix.python-version }}"
50+
cache: 'pip'
51+
- name: Parse Python Version
52+
id: python-semver
53+
run: |
54+
echo "::set-output name=major:$(echo ${{ matrix.python-version }} | cut -d '.' -f 1)"
55+
echo "::set-output name=minor:$(echo ${{ matrix.python-version }} | cut -d '.' -f 2)"
56+
- name: Install Dependencies
57+
run: make install-dev
58+
- name: Display Packages
59+
run: |
60+
pip freeze
61+
make info
62+
- name: Display Environment Variables
63+
run: |
64+
hash -r
65+
env | sort
66+
- name: Run Tests
67+
run: make ${{ matrix.test-case }}

Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,21 @@ install:
3737
@echo "Installing dependencies..."
3838
@pip install ".[processes]"
3939

40+
.PHONY: install-dev
41+
install-dev: install
42+
@echo "Installing development dependencies..."
43+
@pip install ".[dev,processes]"
44+
45+
.PHONY: test-ony
46+
test-only:
47+
@echo "Running tests..."
48+
@pytest "$(APP_ROOT)"
49+
50+
.PHONY: test
51+
test: install-dev test-only
52+
4053
# For each Python file, generate the corresponding CWL file
54+
# Will only run modified Python files by default
4155
%.cwl: %.py
4256
@echo "Generating CWL for [$<]..."
4357
click2cwl \
@@ -53,6 +67,10 @@ cwl-generate-only: $(CWL_CLI_OUTPUTS)
5367
.PHONY: cwl-generate
5468
cwl-generate: cwl-generate-only | install
5569

70+
.PHONY: cwl-generate-all
71+
cwl-generate-all:
72+
$(MAKE) $(foreach file,$(CWL_CLI_SOURCES),-W $(file)) cwl-generate-only
73+
5674
.PHONY: docker-build
5775
docker-build:
5876
@echo "Building Docker image..."

pyproject.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,17 @@ processes = [
3535
"xclim",
3636
"h5netcdf",
3737
]
38+
dev = [
39+
"pytest",
40+
"pytest-cov",
41+
]
42+
43+
[tool.pytest]
44+
addopts = [
45+
"--cov=goldfinch",
46+
"--cov-report=term-missing",
47+
"--cov-report=html",
48+
]
49+
testpaths = [
50+
"tests",
51+
]

0 commit comments

Comments
 (0)