Skip to content

Commit 5506fcb

Browse files
committed
Initial commit
0 parents  commit 5506fcb

37 files changed

Lines changed: 3451 additions & 0 deletions

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosy-luigistem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "monthly"

.github/workflows/benchmarks.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Perform Benchmarks
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- develop
8+
pull_request_target:
9+
branches:
10+
- main
11+
- develop
12+
13+
14+
concurrency:
15+
group: benchmarks-${{ github.event_name }}-${{ github.ref }}
16+
cancel-in-progress: true
17+
18+
19+
env:
20+
PYTHONUNBUFFERED: "1"
21+
FORCE_COLOR: "1"
22+
BRANCH_NAME: ${{ github.base_ref || github.ref_name }}
23+
PUSH_TO_BENCHMARKS: false
24+
COMMENT_ALWAYS: true
25+
26+
jobs:
27+
benchmark-then-upload:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/create-github-app-token@v2
31+
id: cls-python-workflow-token
32+
with:
33+
app-id: ${{ secrets.CLS_PYTHON_WORKFLOW_CLIENT_ID }}
34+
private-key: ${{ secrets.CLS_PYTHON_WORKFLOW_PRIVATE_KEY }}
35+
repositories: |
36+
cosy-luigi
37+
cosy-luigi-benchmarks
38+
39+
- uses: actions/checkout@v6
40+
with:
41+
repository: cls-python/cosy-luigi-benchmarks
42+
ref: 'gh-pages'
43+
44+
- uses: actions/checkout@v6
45+
with:
46+
# Full history for timestamps
47+
fetch-depth: 0
48+
path: 'cosy-luigi-nested'
49+
50+
- name: Set up Python
51+
uses: actions/setup-python@v6
52+
with:
53+
python-version: '3.13'
54+
55+
- name: Install Hatch
56+
uses: pypa/hatch@install
57+
58+
- name: Fetch PR branch from fork
59+
if: ${{ github.event_name == 'pull_request' || github.event_name == 'pull_request_target' }}
60+
run: gh pr checkout ${{ github.event.number }}
61+
env:
62+
GH_TOKEN: ${{ steps.cls-python-workflow-token.outputs.token }}
63+
working-directory: 'cosy-luigi-nested'
64+
65+
- name: Run Benchmark Suite
66+
run: hatch test benchmarks --benchmark-json benchmarks.json
67+
working-directory: 'cosy-luigi-nested'
68+
69+
- name: Config Git
70+
run: |
71+
git config user.name "cls-python-workflows[bot]"
72+
git config user.email "269699678+cls-python-workflows[bot]@users.noreply.github.com"
73+
74+
- name: Determine Push Or Not
75+
if: github.event_name != 'pull_request'
76+
run: |
77+
echo "PUSH_TO_BENCHMARKS=true" >> $GITHUB_ENV
78+
echo "COMMENT_ALWAYS=false" >> $GITHUB_ENV
79+
80+
- name: Store Benchmark Result
81+
uses: benchmark-action/github-action-benchmark@v1
82+
with:
83+
name: Benchmark cosy-luigi
84+
tool: 'pytest'
85+
output-file-path: cosy-luigi-nested/benchmarks.json
86+
github-token: ${{ steps.cls-python-workflow-token.outputs.token }}
87+
auto-push: ${{ env.PUSH_TO_BENCHMARKS }}
88+
alert-threshold: '300%'
89+
comment-on-alert: true
90+
fail-on-alert: true
91+
comment-always: ${{ env.COMMENT_ALWAYS }}
92+
summary-always: true
93+
gh-repository: 'github.com/cls-python/cosy-luigi-benchmarks'
94+
benchmark-data-dir-path: '${{ env.BRANCH_NAME }}/benchmarks'
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: "Nightly Build"
2+
on:
3+
schedule:
4+
- cron: "0 0 * * *"
5+
workflow_dispatch:
6+
7+
env:
8+
nightly_tag: "nightly"
9+
10+
jobs:
11+
build-nightly:
12+
runs-on: ubuntu-latest
13+
if: github.ref == 'refs/heads/develop'
14+
steps:
15+
- uses: actions/create-github-app-token@v2
16+
id: cls-python-workflow-token
17+
with:
18+
app-id: ${{ secrets.CLS_PYTHON_WORKFLOW_CLIENT_ID }}
19+
private-key: ${{ secrets.CLS_PYTHON_WORKFLOW_PRIVATE_KEY }}
20+
21+
- uses: actions/checkout@v6
22+
with:
23+
# Full history for timestamps
24+
fetch-depth: 0
25+
token: ${{ steps.cls-python-workflow-token.outputs.token }}
26+
27+
- name: Date and Hash
28+
run: |
29+
echo "DATESTAMP=$(date +'%d.%m.%Y')" >> $GITHUB_ENV
30+
echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
31+
32+
- name: Set up Python
33+
uses: actions/setup-python@v6
34+
with:
35+
python-version: '3.12'
36+
37+
- name: Install Hatch
38+
uses: pypa/hatch@install
39+
40+
- name: Display Version
41+
run: echo "NIGHTLY_VERSION=$(hatch version)" >> $GITHUB_ENV
42+
43+
- name: Build Package
44+
run: hatch build
45+
46+
- name: Stable Url
47+
run: |
48+
cp dist/cosy_luigi-${{ env.NIGHTLY_VERSION }}.tar.gz dist/cosy_luigi-nightly.tar.gz
49+
50+
- name: Convert nightly to draft
51+
run: gh release edit --draft "${{ env.nightly_tag }}" || true
52+
env:
53+
GH_TOKEN: ${{ steps.cls-python-workflow-token.outputs.token }}
54+
55+
- name: Move nightly tag to current HEAD
56+
run: |
57+
git config user.name "cls-python-workflows[bot]"
58+
git config user.email "269699678+cls-python-workflows[bot]@users.noreply.github.com"
59+
git tag -d ${{ env.nightly_tag }} || true
60+
git push origin :refs/tags/${{ env.nightly_tag }} || true
61+
git tag ${{ env.nightly_tag }}
62+
git push origin ${{ env.nightly_tag }}
63+
env:
64+
GH_TOKEN: ${{ steps.cls-python-workflow-token.outputs.token }}
65+
66+
- name: Publish nightly on GitHub
67+
run: |
68+
while IFS= read -r line; do
69+
gh release delete-asset "${{ env.nightly_tag }}" "$line"
70+
done <<< "$(gh release view "${{ env.nightly_tag }}" --json assets --jq .assets[].name)"
71+
gh release edit \
72+
--verify-tag \
73+
--title "Nightly@${{ env.NIGHTLY_VERSION }}" \
74+
--notes "Nightly build of ''develop'', currently at ${{ env.COMMIT_HASH }}, built on ${{ env.DATESTAMP }}." \
75+
--draft=false \
76+
"${{ env.nightly_tag }}"
77+
gh release upload --clobber "${{ env.nightly_tag }}" $ARTIFACTS
78+
env:
79+
GH_TOKEN: ${{ steps.cls-python-workflow-token.outputs.token }}
80+
ARTIFACTS: >
81+
dist/cosy_luigi-${{ env.NIGHTLY_VERSION }}.tar.gz
82+
dist/cosy_luigi-nightly.tar.gz
83+
dist/cosy_luigi-${{ env.NIGHTLY_VERSION }}-py3-none-any.whl
84+

.github/workflows/check-docs.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Check Docs
2+
3+
on:
4+
workflow_call:
5+
push:
6+
branches:
7+
- main
8+
- develop
9+
pull_request:
10+
branches:
11+
- main
12+
- develop
13+
14+
concurrency:
15+
group: check-docs-${{ github.event_name }}-${{ github.ref }}
16+
cancel-in-progress: true
17+
18+
jobs:
19+
check-docs:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v6
23+
with:
24+
# Full history for timestamps
25+
fetch-depth: 0
26+
27+
- name: Set up Python
28+
uses: actions/setup-python@v6
29+
with:
30+
python-version: '3.12'
31+
32+
- name: Install Hatch
33+
uses: pypa/hatch@install
34+
35+
- name: Build and Check
36+
run: hatch run docs:check

.github/workflows/checks.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Perform Checks
2+
3+
on:
4+
workflow_call:
5+
push:
6+
branches:
7+
- main
8+
- develop
9+
pull_request:
10+
branches:
11+
- main
12+
- develop
13+
14+
15+
concurrency:
16+
group: checks-${{ github.event_name }}-${{ github.ref }}
17+
cancel-in-progress: true
18+
19+
20+
env:
21+
PYTHONUNBUFFERED: "1"
22+
FORCE_COLOR: "1"
23+
BRANCH_NAME: ${{ github.base_ref || github.ref_name }}
24+
25+
jobs:
26+
test-lint-type-coverage:
27+
name: Python ${{ matrix.python-version }} on ${{ startsWith(matrix.os, 'macos-') && 'macOS' || startsWith(matrix.os, 'windows-') && 'Windows' || 'Linux' }}
28+
runs-on: ${{ matrix.os }}
29+
env:
30+
OS: ${{ matrix.os }}
31+
PYTHON: ${{ matrix.python-version }}
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
os: [ubuntu-latest, windows-latest, macos-latest]
36+
python-version: ['3.10', '3.11', '3.12', '3.13']
37+
38+
steps:
39+
- uses: actions/checkout@v6
40+
41+
- name: Set up Python ${{ matrix.python-version }}
42+
uses: actions/setup-python@v6
43+
with:
44+
python-version: ${{ matrix.python-version }}
45+
46+
- name: Install Hatch
47+
uses: pypa/hatch@install
48+
49+
- name: Run static analysis
50+
run: hatch fmt --check
51+
52+
- name: Run type checks
53+
run: hatch run types:check
54+
55+
- name: Run tests
56+
run: hatch test tests --python ${{ matrix.python-version }} --cov --cov-branch --cov-report=xml --randomize --parallel --junit-xml=report.xml
57+
58+
- name: Upload Tests to Codecov
59+
if: ${{ !cancelled() && !contains( github.head_ref, 'hotfix/')}}
60+
uses: codecov/codecov-action@v5
61+
with:
62+
token: ${{ secrets.CODECOV_TOKEN }}
63+
files: ./report.xml
64+
report_type: test_results
65+
flags: ${{ matrix.os }}-${{ matrix.python-version }}
66+
67+
- name: Upload Coverage to Codecov
68+
uses: codecov/codecov-action@v5
69+
if: ${{ !contains( github.head_ref, 'hotfix/') }}
70+
with:
71+
token: ${{ secrets.CODECOV_TOKEN }}
72+
files: ./coverage.xml
73+
flags: ${{ matrix.os }}-${{ matrix.python-version }}

.github/workflows/deploy-docs.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Deploy Documentation
2+
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
pages: write
12+
13+
concurrency:
14+
group: deploy-docs
15+
cancel-in-progress: true
16+
17+
jobs:
18+
pre-deploy-docs-checks:
19+
uses: ./.github/workflows/check-docs.yml
20+
21+
deploy-docs:
22+
needs: [pre-deploy-docs-checks]
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v6
26+
with:
27+
# Full history for timestamps
28+
fetch-depth: 0
29+
30+
- name: Set up Python
31+
uses: actions/setup-python@v6
32+
with:
33+
python-version: '3.12'
34+
35+
- name: Install Hatch
36+
uses: pypa/hatch@install
37+
38+
- name: Display Version
39+
run: hatch version
40+
41+
- name: Configure Git for Actions
42+
run: |
43+
git config --local user.name 'cls-python-workflows[bot]'
44+
git config --local user.email '269699678+cls-python-workflows[bot]@users.noreply.github.com'
45+
46+
- name: Publish
47+
run: hatch run docs:deploy
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: 'Check PR Rules for Develop'
2+
3+
on:
4+
pull_request_target:
5+
types: [ opened, reopened ]
6+
branches:
7+
- develop
8+
9+
env:
10+
PR_NUMBER: ${{ github.event.number }}
11+
12+
jobs:
13+
pr-rules-develop:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
checks: write
17+
pull-requests: write
18+
steps:
19+
- uses: actions/create-github-app-token@v2
20+
id: cls-python-workflow-token
21+
with:
22+
app-id: ${{ secrets.CLS_PYTHON_WORKFLOW_CLIENT_ID }}
23+
private-key: ${{ secrets.CLS_PYTHON_WORKFLOW_PRIVATE_KEY }}
24+
25+
- uses: actions/checkout@v6
26+
with:
27+
# Full history for timestamps
28+
fetch-depth: 0
29+
token: ${{ steps.cls-python-workflow-token.outputs.token }}
30+
31+
- name: Close Pull Request and Comment if Violating
32+
if: ${{ !contains( github.head_ref, 'feature/') && !contains( github.head_ref, 'bugfix/') && !contains( github.head_ref, 'dependabot/github_actions/') && !contains( github.head_ref, 'main')}}
33+
run: |
34+
gh pr comment ${{ env.PR_NUMBER }} --body ":warning: You can only merge to develop from a feature or a bugfix branch. :warning:"
35+
gh pr close ${{ env.PR_NUMBER }}
36+
env:
37+
GH_TOKEN: ${{ steps.cls-python-workflow-token.outputs.token }}
38+
39+
- name: Fail Job if Violating
40+
if: ${{ !contains( github.head_ref, 'feature/') && !contains( github.head_ref, 'bugfix/') && !contains( github.head_ref, 'dependabot/github_actions/') && !contains( github.head_ref, 'main')}}
41+
run: |
42+
echo "Reason: You can only merge to develop from a feature or a bugfix branch."
43+
exit 1
44+
45+
- name: Succeed Job if not Violating
46+
if: ${{ contains( github.head_ref, 'feature/') || contains( github.head_ref, 'bugfix/') || contains( github.head_ref, 'dependabot/github_actions/') && !contains( github.head_ref, 'main')}}
47+
run: |
48+
exit 0

0 commit comments

Comments
 (0)