Skip to content

Commit f5061b5

Browse files
authored
Enable CI via GH actions (#129)
1 parent 1bc5c76 commit f5061b5

File tree

3 files changed

+179
-0
lines changed

3 files changed

+179
-0
lines changed

.github/workflows/release.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
deploy:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v3
14+
15+
- name: Setup Python
16+
uses: actions/setup-python@v4
17+
with:
18+
python-version: "3.x"
19+
20+
- name: Build package
21+
run: pipx run build
22+
23+
- name: Publish to Test PyPi
24+
if: ${{ startsWith(github.ref, 'refs/tags') }}
25+
uses: pypa/gh-action-pypi-publish@master
26+
with:
27+
user: __token__
28+
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
29+
repository_url: https://test.pypi.org/legacy/
30+
31+
- name: Publish to PyPi
32+
if: ${{ startsWith(github.ref, 'refs/tags') }}
33+
uses: pypa/gh-action-pypi-publish@master
34+
with:
35+
user: __token__
36+
password: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/test.yml

+138
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
schedule:
7+
- cron: "0 0 * * 3"
8+
workflow_dispatch:
9+
10+
jobs:
11+
resources:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v2
16+
17+
- name: Create resource cache
18+
id: cache
19+
uses: actions/cache@v3
20+
with:
21+
path: ./fortran_tests/before/*/
22+
key: resources-${{ github.event_name }}
23+
24+
- name: Prepare tests (default)
25+
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
26+
run: |
27+
.travis/prep_regular.sh
28+
29+
- name: Prepare tests (schedule)
30+
if: ${{ steps.cache.outputs.cache-hit != 'true' && github.event_name == 'schedule' }}
31+
run: |
32+
.travis/prep_cron.sh
33+
34+
conda:
35+
needs:
36+
- resources
37+
runs-on: ${{ matrix.os }}
38+
strategy:
39+
fail-fast: false
40+
matrix:
41+
os: [ubuntu-latest]
42+
python: ["3.7", "3.8", "3.9", "3.10"]
43+
44+
defaults:
45+
run:
46+
shell: "bash -l {0}"
47+
48+
steps:
49+
- name: Checkout code
50+
uses: actions/checkout@v2
51+
52+
- name: Load resources
53+
uses: actions/cache@v3
54+
with:
55+
path: ./fortran_tests/before/*/
56+
key: resources-${{ github.event_name }}
57+
58+
- name: Install dependencies
59+
uses: mamba-org/provision-with-micromamba@main
60+
with:
61+
environment-file: environment.yml
62+
extra-specs: |
63+
python=${{ matrix.python }}
64+
coveralls
65+
66+
- name: Install project
67+
run: pip install .
68+
69+
- name: Run tests
70+
run: |
71+
coverage run --source=fprettify setup.py test
72+
73+
- name: Coverage upload
74+
run: coveralls --service=github
75+
env:
76+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77+
COVERALLS_FLAG_NAME: ${{ matrix.python }}
78+
COVERALLS_PARALLEL: true
79+
80+
pip:
81+
needs:
82+
- resources
83+
runs-on: ${{ matrix.os }}
84+
strategy:
85+
fail-fast: false
86+
matrix:
87+
os: [ubuntu-latest]
88+
python: ["3.5", "3.6"]
89+
90+
steps:
91+
- name: Checkout code
92+
uses: actions/checkout@v2
93+
94+
- name: Load resources
95+
uses: actions/cache@v3
96+
with:
97+
path: ./fortran_tests/before/*/
98+
key: resources-${{ github.event_name }}
99+
100+
- uses: actions/setup-python@v3
101+
with:
102+
python-version: ${{ matrix.python }}
103+
104+
- name: Install dependencies
105+
run: pip install -r requirements.txt coveralls
106+
107+
- name: Install project
108+
run: pip install .
109+
110+
- name: Run tests
111+
run: |
112+
coverage run --source=fprettify setup.py test
113+
114+
- name: Coverage upload
115+
run: coveralls --service=github
116+
env:
117+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
118+
COVERALLS_FLAG_NAME: ${{ matrix.python }}
119+
COVERALLS_PARALLEL: true
120+
121+
coverage:
122+
needs:
123+
- pip
124+
- conda
125+
runs-on: ubuntu-latest
126+
127+
steps:
128+
- uses: actions/setup-python@v3
129+
with:
130+
python-version: '3.x'
131+
132+
- name: Install dependencies
133+
run: pip install coveralls
134+
135+
- name: Coverage upload
136+
run: coveralls --service=github --finish
137+
env:
138+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

environment.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name: devel
2+
channels:
3+
- conda-forge
4+
dependencies:
5+
- configargparse

0 commit comments

Comments
 (0)