Skip to content
This repository was archived by the owner on Nov 4, 2024. It is now read-only.

Commit f3c9860

Browse files
committed
Initial commit
0 parents  commit f3c9860

32 files changed

+1459
-0
lines changed

.github/dependabot.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
# - package-ecosystem: pip
4+
# directory: "/"
5+
# schedule:
6+
# interval: daily
7+
- package-ecosystem: 'github-actions'
8+
directory: '/'
9+
schedule:
10+
# Check for updates once a week
11+
interval: 'weekly'

.github/workflows/ci.yaml

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: CI
2+
on:
3+
push:
4+
pull_request:
5+
schedule:
6+
- cron: '0 0 * * *' # Daily “At 00:00”
7+
workflow_dispatch: # allows you to trigger manually
8+
9+
jobs:
10+
skip-duplicate-jobs:
11+
runs-on: ubuntu-latest
12+
if: |
13+
github.repository == 'ncar-xdev/python-project-template'
14+
outputs:
15+
should_skip: ${{ steps.skip_check.outputs.should_skip }}
16+
steps:
17+
- id: skip_check
18+
uses: fkirc/[email protected]
19+
with:
20+
# For workflows which are triggered concurrently with the same
21+
# contents, attempt to execute them exactly once.
22+
concurrent_skipping: 'same_content_newer'
23+
paths_ignore: '["**/doc/**"]'
24+
25+
build:
26+
name: python-${{ matrix.python-version }}
27+
needs: skip-duplicate-jobs
28+
if: ${{ needs.skip-duplicate-jobs.outputs.should_skip != 'true' }}
29+
runs-on: ubuntu-latest
30+
defaults:
31+
run:
32+
shell: bash -l {0}
33+
strategy:
34+
fail-fast: false
35+
matrix:
36+
python-version: ['3.8', '3.9', '3.10']
37+
steps:
38+
- uses: actions/checkout@v2
39+
- uses: conda-incubator/setup-miniconda@v2
40+
with:
41+
channels: conda-forge,nodefaults
42+
channel-priority: strict
43+
activate-environment: xdev-project-dev
44+
auto-update-conda: false
45+
python-version: ${{ matrix.python-version }}
46+
environment-file: ci/environment.yml
47+
mamba-version: '*'
48+
use-mamba: true
49+
miniforge-variant: Mambaforge
50+
51+
- name: Install xdev-project
52+
run: |
53+
python -m pip install -e . --no-deps --force-reinstall
54+
conda list
55+
56+
- name: Run Tests
57+
run: |
58+
python -m pytest
59+
60+
- name: Upload code coverage to Codecov
61+
uses: codecov/[email protected]
62+
with:
63+
file: ./coverage.xml
64+
flags: unittests
65+
env_vars: OS,PYTHON
66+
name: codecov-umbrella
67+
fail_ci_if_error: false

.github/workflows/pypi-release.yaml

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Build distribution
2+
on:
3+
release:
4+
types:
5+
- published
6+
push:
7+
8+
jobs:
9+
build-artifacts:
10+
runs-on: ubuntu-latest
11+
if: github.repository == 'ncar-xdev/python-project-template'
12+
steps:
13+
- uses: actions/checkout@v2
14+
with:
15+
fetch-depth: 0
16+
- uses: actions/[email protected]
17+
name: Install Python
18+
with:
19+
python-version: 3.8
20+
21+
- name: Install dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
python -m pip install setuptools setuptools-scm wheel twine check-manifest
25+
26+
- name: Build tarball and wheels
27+
run: |
28+
git clean -xdf
29+
git restore -SW .
30+
python -m build --sdist --wheel .
31+
32+
- name: Check built artifacts
33+
run: |
34+
python -m twine check dist/*
35+
pwd
36+
if [ -f dist/xdev-project-0.0.0.tar.gz ]; then
37+
echo "❌ INVALID VERSION NUMBER"
38+
exit 1
39+
else
40+
echo "✅ Looks good"
41+
fi
42+
- uses: actions/upload-artifact@v2
43+
with:
44+
name: releases
45+
path: dist
46+
47+
test-built-dist:
48+
needs: build-artifacts
49+
runs-on: ubuntu-latest
50+
steps:
51+
- uses: actions/[email protected]
52+
name: Install Python
53+
with:
54+
python-version: 3.8
55+
- uses: actions/download-artifact@v2
56+
with:
57+
name: releases
58+
path: dist
59+
- name: List contents of built dist
60+
run: |
61+
ls -ltrh
62+
ls -ltrh dist
63+
64+
upload-to-pypi:
65+
needs: test-built-dist
66+
if: github.event_name == 'release'
67+
runs-on: ubuntu-latest
68+
steps:
69+
- uses: actions/download-artifact@v2
70+
with:
71+
name: releases
72+
path: dist
73+
- name: Publish package to PyPI
74+
uses: pypa/[email protected]
75+
with:
76+
user: __token__
77+
password: ${{ secrets.PYPI_TOKEN }}
78+
verbose: true
+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Upstream CI
2+
on:
3+
push:
4+
schedule:
5+
- cron: '0 0 * * *' # Daily “At 00:00” UTC
6+
workflow_dispatch: # allows you to trigger the workflow run manually
7+
8+
jobs:
9+
upstream-dev:
10+
name: upstream-dev
11+
runs-on: ubuntu-latest
12+
defaults:
13+
run:
14+
shell: bash -l {0}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
python-version: ['3.10']
19+
steps:
20+
- uses: actions/checkout@v2
21+
- uses: conda-incubator/setup-miniconda@v2
22+
id: conda
23+
with:
24+
channels: conda-forge,nodefaults
25+
channel-priority: strict
26+
activate-environment: xdev-project-dev
27+
auto-update-conda: false
28+
python-version: ${{ matrix.python-version }}
29+
environment-file: ci/upstream-dev-environment.yml
30+
mamba-version: '*'
31+
use-mamba: true
32+
miniforge-variant: Mambaforge
33+
34+
- name: Install xdev-project
35+
id: install
36+
run: |
37+
python -m pip install -e . --no-deps --force-reinstall
38+
conda list
39+
40+
- name: Run Tests
41+
id: test
42+
run: |
43+
python -m pytest
44+
45+
- name: Report Status
46+
if: |
47+
always()
48+
&& (steps.conda.outcome != 'success' || steps.install.outcome != 'success' || steps.install.outcome != 'success')
49+
50+
uses: actions/github-script@v6
51+
with:
52+
script: |
53+
const title = '⚠️ Upstream CI Failed ⚠️'
54+
const creator = 'github-actions[bot]'
55+
const issueLabel = 'CI'
56+
const workflow_url = `https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`
57+
const issue_body = `[Workflow Run URL](${workflow_url})\n\n`
58+
let foundIssue = false
59+
const issues = await github.rest.issues.listForRepo({
60+
owner: context.repo.owner,
61+
repo: context.repo.repo,
62+
})
63+
for (let issue of issues.data) {
64+
if (
65+
issue.user.login === creator &&
66+
issue.state === 'open' &&
67+
issue.labels.some((label) => label.name === issueLabel)
68+
) {
69+
github.rest.issues.update({
70+
owner: context.repo.owner,
71+
repo: context.repo.repo,
72+
issue_number: issue.number,
73+
body: issue_body,
74+
})
75+
core.info(`Updated an existing issue: ${issue.number}.`)
76+
foundIssue = true
77+
break
78+
}
79+
}
80+
if (!foundIssue) {
81+
await github.rest.issues.create({
82+
owner: context.repo.owner,
83+
repo: context.repo.repo,
84+
title: title,
85+
body: issue_body,
86+
labels: [issueLabel],
87+
})
88+
core.info('Opened a new issue')
89+
}

.gitignore

+135
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
pip-wheel-metadata/
24+
share/python-wheels/
25+
*.egg-info/
26+
.installed.cfg
27+
*.egg
28+
MANIFEST
29+
30+
# PyInstaller
31+
# Usually these files are written by a python script from a template
32+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33+
*.manifest
34+
*.spec
35+
36+
# Installer logs
37+
pip-log.txt
38+
pip-delete-this-directory.txt
39+
40+
# Unit test / coverage reports
41+
htmlcov/
42+
.tox/
43+
.nox/
44+
.coverage
45+
.coverage.*
46+
.cache
47+
nosetests.xml
48+
coverage.xml
49+
*.cover
50+
*.py,cover
51+
.hypothesis/
52+
.pytest_cache/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
target/
76+
77+
# Jupyter Notebook
78+
.ipynb_checkpoints
79+
80+
# IPython
81+
profile_default/
82+
ipython_config.py
83+
84+
# pyenv
85+
.python-version
86+
87+
# pipenv
88+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
90+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
91+
# install all needed dependencies.
92+
#Pipfile.lock
93+
94+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
95+
__pypackages__/
96+
97+
# Celery stuff
98+
celerybeat-schedule
99+
celerybeat.pid
100+
101+
# SageMath parsed files
102+
*.sage.py
103+
104+
# Environments
105+
.env
106+
.venv
107+
env/
108+
venv/
109+
ENV/
110+
env.bak/
111+
venv.bak/
112+
113+
# Spyder project settings
114+
.spyderproject
115+
.spyproject
116+
117+
# Rope project settings
118+
.ropeproject
119+
120+
# mkdocs documentation
121+
/site
122+
123+
# mypy
124+
.mypy_cache/
125+
.dmypy.json
126+
dmypy.json
127+
128+
# Pyre type checker
129+
.pyre/
130+
131+
# Dask
132+
dask-worker-space/
133+
134+
# Vscode
135+
.vscode/

0 commit comments

Comments
 (0)