Skip to content

Commit 0e7353f

Browse files
committed
CI: Refactoring CI/CD for more efficiency
Signed-off-by: HarshCasper <erbeusgriffincasper@gmail.com>
1 parent 2e466c5 commit 0e7353f

File tree

3 files changed

+60
-12
lines changed

3 files changed

+60
-12
lines changed

.github/workflows/ci.yml

Lines changed: 52 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,65 @@
1-
# This workflow will install Conda environment, run tests and lint with a single version of Python.
2-
31
name: Continuous Integration
42

53
on:
4+
schedule:
5+
- cron: "0 0 * * MON"
6+
push:
7+
branches: [ master ]
68
pull_request:
7-
branches: [ main, master ]
9+
branches: [ master ]
810
workflow_dispatch:
911

1012
jobs:
1113
ci:
1214
name: CI
1315
runs-on: ubuntu-latest
14-
env:
15-
DOCKER_BUILDKIT: "1"
16+
1617
steps:
1718
- name: Checkout code
1819
uses: actions/checkout@v2
19-
- name: Lint using pylint
20-
run: docker build . --target lint
21-
- name: Test using pytest
22-
run: docker build . --target unit-test
20+
21+
- name: Setup Python
22+
uses: actions/setup-python@v2
23+
with:
24+
python-version: 3.7
25+
26+
- name: Setup Conda
27+
uses: conda-incubator/setup-miniconda@v2
28+
with:
29+
python-version: 3.7
30+
mamba-version: "*"
31+
channels: conda-forge
32+
channel-priority: true
33+
activate-environment: taswira
34+
35+
- name: Cache conda
36+
uses: actions/cache@v2
37+
env:
38+
# Increase this value to reset cache if environment.yml has not changed
39+
CACHE_NUMBER: 0
40+
with:
41+
path: /usr/local/miniconda/envs/taswira
42+
key:
43+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('environment.yml') }}
44+
id: envcache
45+
46+
- name: Update Conda Environment
47+
run: mamba env update -n taswira -f environment.yml
48+
49+
- name: Install Python package
50+
shell: bash -l {0}
51+
run: |
52+
conda activate taswira
53+
python -m pip install -e .
54+
55+
- name: Run Black
56+
run: |
57+
python -m pip install black
58+
black src --diff
59+
black --check src
60+
61+
- name: Test
62+
shell: bash -l {0}
63+
run: |
64+
conda activate taswira
65+
python -m pytest
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
name: Taswira CD
1+
name: Docker CI/CD
22

33
on:
44
schedule:
55
- cron: "0 0 * * MON"
6-
6+
pull_request:
7+
branches: [ master ]
78
push:
89
branches: [ master ]
910
# Publish semver tags as releases.
1011
tags: [ 'v*.*.*' ]
12+
workflow_dispatch:
1113

1214
env:
1315
REGISTRY: ghcr.io
@@ -28,6 +30,7 @@ jobs:
2830
uses: docker/setup-buildx-action@v1
2931

3032
- name: Log into GitHub Container Registry
33+
if: ${{ github.event_name != 'pull_request' }}
3134
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
3235
with:
3336
registry: ${{ env.REGISTRY }}
@@ -44,7 +47,7 @@ jobs:
4447
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
4548
with:
4649
context: .
47-
push: true
50+
push: ${{ github.event_name != 'pull_request' }}
4851
tags: ${{ steps.meta.outputs.tags }}
4952
labels: ${{ steps.meta.outputs.labels }}
5053
cache-from: type=gha

environment.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ dependencies:
1515
- pylint>=2.5.2
1616
- dash==1.13.3
1717
- dash-leaflet==0.0.19
18+
- markupsafe<2.1
19+
- jinja2

0 commit comments

Comments
 (0)