Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add 2 workflows and script/conf associated + define style linter #36

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
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
85 changes: 85 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: CI

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

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
detect-skip-ci-trigger:
name: "Detect CI Trigger: [skip-ci]"
if: |
github.repository == 'umr-lops/xradarsat2'
&& (
github.event_name == 'push' || github.event_name == 'pull_request'
)
runs-on: ubuntu-latest
outputs:
triggered: ${{ steps.detect-trigger.outputs.trigger-found }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- uses: xarray-contrib/ci-trigger@v1
id: detect-trigger
with:
keyword: "[skip-ci]"

ci:
name: ${{ matrix.os }} py${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
needs: detect-skip-ci-trigger

if: needs.detect-skip-ci-trigger.outputs.triggered == 'false'

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

strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
os: ["ubuntu-latest", "macos-latest", "windows-latest"]

steps:
- name: Checkout the repository
uses: actions/checkout@v4
with:
# need to fetch all tags to get a correct version
fetch-depth: 0 # fetch all branches and tags

- name: Setup environment variables
run: |
echo "TODAY=$(date +'%Y-%m-%d')" >> $GITHUB_ENV

echo "CONDA_ENV_FILE=ci/requirements/environment.yaml" >> $GITHUB_ENV

- name: Setup micromamba
uses: mamba-org/setup-micromamba@v2
with:
environment-file: ${{ env.CONDA_ENV_FILE }}
environment-name: xradarsat2-tests
cache-environment: true
generate-run-shell: true
cache-environment-key: "${{runner.os}}-${{runner.arch}}-py${{matrix.python-version}}-${{env.TODAY}}-${{hashFiles(env.CONDA_ENV_FILE)}}"
create-args: >-
python=${{matrix.python-version}}

- name: Install xradarsat2
run: |
python -m pip install --no-deps -e .

- name: Import xradarsat2
run: |
python -c "import xradarsat2"

- name: Run tests
run: |
python -m pytest --cov=xradarsat2
98 changes: 98 additions & 0 deletions .github/workflows/upstream-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: upstream-dev CI

on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: "0 18 * * 0" # Weekly "On Sundays at 18:00" UTC
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
detect-test-upstream-trigger:
name: "Detect CI Trigger: [test-upstream]"
if: github.event_name == 'push' || github.event_name == 'pull_request'
runs-on: ubuntu-latest
outputs:
triggered: ${{ steps.detect-trigger.outputs.trigger-found }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- uses: xarray-contrib/[email protected]
id: detect-trigger
with:
keyword: "[test-upstream]"

upstream-dev:
name: upstream-dev
runs-on: ubuntu-latest
needs: detect-test-upstream-trigger

if: |
always()
&& github.repository == 'umr-lops/xradarsat2'
&& (
github.event_name == 'schedule'
|| github.event_name == 'workflow_dispatch'
|| needs.detect-test-upstream-trigger.outputs.triggered == 'true'
|| contains(github.event.pull_request.labels.*.name, 'run-upstream')
)

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

strategy:
fail-fast: false
matrix:
python-version: ["3.12"]

steps:
- name: checkout the repository
uses: actions/checkout@v4
with:
# need to fetch all tags to get a correct version
fetch-depth: 0 # fetch all branches and tags

- name: set up conda environment
uses: mamba-org/setup-micromamba@v1
with:
environment-file: ci/requirements/environment.yaml
environment-name: tests
create-args: >-
python=${{ matrix.python-version }}
pytest-reportlog

- name: install upstream-dev dependencies
run: bash ci/install-upstream-dev.sh

- name: install the package
run: python -m pip install --no-deps -e .

- name: show versions
run: python -m pip list

- name: import
run: |
python -c 'import xradarsat2'

- name: run tests
if: success()
id: status
run: |
python -m pytest -rf --report-log=pytest-log.jsonl

- name: report failures
if: |
failure()
&& steps.tests.outcome == 'failure'
&& github.event_name == 'schedule'
uses: xarray-contrib/issue-from-pytest-log@v1
with:
log-path: pytest-log.jsonl
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,4 @@ tmp/
/.idea/

dask-worker-space/
localxradarsat2-config.yaml
localxradarsat2-config.yaml
14 changes: 14 additions & 0 deletions ci/install-upstream-dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

conda remove -y --force cytoolz numpy xarray toolz python-dateutil rioxarray
python -m pip install \
-i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple \
--no-deps \
--pre \
--upgrade \
numpy \
rioxarray \
xarray
python -m pip install --upgrade \
git+https://github.com/pytoolz/toolz \
git+https://github.com/dateutil/dateutil
8 changes: 8 additions & 0 deletions ci/requirements/docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: xradarsat2-docs
channels:
- conda-forge
dependencies:
- python=3.11
- sphinx>=4
- sphinx_book_theme
- ipython
26 changes: 26 additions & 0 deletions ci/requirements/environment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: xradarsat2-tests
channels:
- conda-forge
dependencies:
- python
- ipython
- pre-commit
- pytest
- pytest-reportlog
- pytest-cov
- numpy
- toolz
- cytoolz
- python-dateutil
- construct
- xarray
- rioxarray>=0.17.0
- aiohttp
- fsspec
- dask
- opencv
- pyyaml
- affine
- h5netcdf
- scipy
- xmltodict
20 changes: 7 additions & 13 deletions docs/doc_xradarsat2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "03cfc89b-5ee1-49c2-8bc9-ca88c00eb63b",
"id": "0",
"metadata": {},
"source": [
"# examples"
Expand All @@ -11,7 +11,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "9f901d61-adf5-4ad2-a721-b92fb8555642",
"id": "1",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -23,7 +23,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "84c1a31d-c27c-4614-8a39-f4dca2801bf6",
"id": "2",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -36,7 +36,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "90fb68ff-2c19-4432-8d95-98159ee546a8",
"id": "3",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -48,7 +48,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "ff1730a0-caeb-4c53-8fa0-85c79adfb5a6",
"id": "4",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -59,7 +59,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "6f74bb35-b8d0-4a17-82d2-4b151e3044fb",
"id": "5",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -74,11 +74,6 @@
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
Expand All @@ -88,8 +83,7 @@
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.0"
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
Expand Down
Loading
Loading