Skip to content

Commit

Permalink
CI: Refactoring CI/CD for more efficiency
Browse files Browse the repository at this point in the history
  • Loading branch information
HarshCasper committed Mar 2, 2022
1 parent f00be4c commit 02e4144
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 12 deletions.
61 changes: 52 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,65 @@
# This workflow will install Conda environment, run tests and lint with a single version of Python.

name: Continuous Integration

on:
schedule:
- cron: "0 0 * * MON"
push:
branches: [ master ]
pull_request:
branches: [ main, master ]
branches: [ master ]
workflow_dispatch:

jobs:
ci:
name: CI
runs-on: ubuntu-latest
env:
DOCKER_BUILDKIT: "1"

steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Lint using pylint
run: docker build . --target lint
- name: Test using pytest
run: docker build . --target unit-test

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.7

- name: Setup Conda
uses: conda-incubator/setup-miniconda@v2
with:
python-version: 3.7
mamba-version: "*"
channels: conda-forge
channel-priority: true
activate-environment: taswira

- name: Cache conda
uses: actions/cache@v2
env:
# Increase this value to reset cache if environment.yml has not changed
CACHE_NUMBER: 0
with:
path: /usr/local/miniconda/envs/taswira
key:
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('environment.yml') }}
id: envcache

- name: Update Conda Environment
run: mamba env update -n taswira -f environment.yml

- name: Install Python package
shell: bash -l {0}
run: |
conda activate taswira
python -m pip install -e .
- name: Run Black
run: |
python -m pip install black
black src --diff
black --check src
- name: Test
shell: bash -l {0}
run: |
conda activate taswira
python -m pytest
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
name: Taswira CD
name: Docker CI/CD

on:
schedule:
- cron: "0 0 * * MON"

pull_request:
branches: [ master ]
push:
branches: [ master ]
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
workflow_dispatch:

env:
REGISTRY: ghcr.io
Expand All @@ -28,6 +30,7 @@ jobs:
uses: docker/setup-buildx-action@v1

- name: Log into GitHub Container Registry
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
with:
registry: ${{ env.REGISTRY }}
Expand All @@ -44,7 +47,7 @@ jobs:
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: true
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
Expand Down
2 changes: 2 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ dependencies:
- pylint>=2.5.2
- dash==1.13.3
- dash-leaflet==0.0.19
- markupsafe<2.1
- jinja2

0 comments on commit 02e4144

Please sign in to comment.