diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a81bd27..89b562c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/docker.yml similarity index 86% rename from .github/workflows/publish.yml rename to .github/workflows/docker.yml index 0782d4d..45c3618 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/docker.yml @@ -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 @@ -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 }} @@ -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 diff --git a/environment.yml b/environment.yml index 92a8ec2..1affecc 100644 --- a/environment.yml +++ b/environment.yml @@ -15,3 +15,5 @@ dependencies: - pylint>=2.5.2 - dash==1.13.3 - dash-leaflet==0.0.19 + - markupsafe<2.1 + - jinja2