diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 89b562c..4c4b4b0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,6 +2,7 @@ name: Continuous Integration on: schedule: + # Run this workflow at 00:00 on every Monday - cron: "0 0 * * MON" push: branches: [ master ] @@ -10,8 +11,8 @@ on: workflow_dispatch: jobs: - ci: - name: CI + build-test-taswira: + name: Build and Test Taswira runs-on: ubuntu-latest steps: @@ -38,12 +39,14 @@ jobs: # Increase this value to reset cache if environment.yml has not changed CACHE_NUMBER: 0 with: + # Cache the path where dependencies are installed with a key unique to the existing environment.yml path: /usr/local/miniconda/envs/taswira key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('environment.yml') }} id: envcache - name: Update Conda Environment + # Setup (or update) the environment for faster installs run: mamba env update -n taswira -f environment.yml - name: Install Python package @@ -60,6 +63,7 @@ jobs: - name: Test shell: bash -l {0} + # Test the package run: | conda activate taswira - python -m pytest \ No newline at end of file + python -m pytest diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 45c3618..bb5e9ca 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -2,6 +2,7 @@ name: Docker CI/CD on: schedule: + # Run this workflow at 00:00 on every Monday - cron: "0 0 * * MON" pull_request: branches: [ master ] @@ -40,6 +41,7 @@ jobs: - name: Extract Docker metadata id: meta uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + # It will push the image to ghcr.io/moja-global/taswira:master on push with: images: ${{ env.REGISTRY }}/moja-global/taswira @@ -47,8 +49,10 @@ jobs: uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc with: context: . + # Prevent push to GHCR on pull requests push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + # Implement Docker build caching for faster builds cache-from: type=gha cache-to: type=gha,mode=max