From 110c5479c2a27c8114284c8562265e660f73d767 Mon Sep 17 00:00:00 2001 From: Tony Chan Date: Mon, 18 Nov 2024 13:47:00 -0500 Subject: [PATCH 1/5] Try to cache the env --- .github/workflows/meal_identification.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/meal_identification.yml b/.github/workflows/meal_identification.yml index ef0717d..26afd7e 100644 --- a/.github/workflows/meal_identification.yml +++ b/.github/workflows/meal_identification.yml @@ -5,7 +5,7 @@ on: jobs: build-linux: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 defaults: run: working-directory: ./0_meal_identification/meal_identification @@ -13,6 +13,12 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Cache conda env + uses: actions/cache@v3 + with: + path: /usr/share/miniconda/envs/meal_identification_ci + key: conda-${{ runner.os }}-${{ hashFiles('./0_meal_identification/meal_identification/environment-ci.yml') }} + - name: Setup Conda uses: conda-incubator/setup-miniconda@v3 with: From 5d51cd851b2f2ae097325a402f28dfb4a52655f3 Mon Sep 17 00:00:00 2001 From: Tony Chan Date: Mon, 18 Nov 2024 13:47:56 -0500 Subject: [PATCH 2/5] Try to cache the env --- .github/workflows/meal_identification.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/meal_identification.yml b/.github/workflows/meal_identification.yml index 26afd7e..cc30bc9 100644 --- a/.github/workflows/meal_identification.yml +++ b/.github/workflows/meal_identification.yml @@ -1,5 +1,7 @@ name: Meal Identification on: + push: + branches: [ main ] pull_request: branches: [ main ] From df8f5c82189052d55153d1c4d915fe0ffa575f4f Mon Sep 17 00:00:00 2001 From: Tony Chan Date: Mon, 18 Nov 2024 14:08:49 -0500 Subject: [PATCH 3/5] Try to cache the env --- .github/workflows/meal_identification.yml | 10 +++++----- .../meal_identification/environment-ci.yml | 3 +-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/meal_identification.yml b/.github/workflows/meal_identification.yml index cc30bc9..cb4cd61 100644 --- a/.github/workflows/meal_identification.yml +++ b/.github/workflows/meal_identification.yml @@ -15,11 +15,11 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Cache conda env - uses: actions/cache@v3 - with: - path: /usr/share/miniconda/envs/meal_identification_ci - key: conda-${{ runner.os }}-${{ hashFiles('./0_meal_identification/meal_identification/environment-ci.yml') }} +# - name: Cache conda env +# uses: actions/cache@v3 +# with: +# path: /usr/share/miniconda/envs/meal_identification_ci +# key: conda-${{ runner.os }}-${{ hashFiles('./0_meal_identification/meal_identification/environment-ci.yml') }} - name: Setup Conda uses: conda-incubator/setup-miniconda@v3 diff --git a/0_meal_identification/meal_identification/environment-ci.yml b/0_meal_identification/meal_identification/environment-ci.yml index be94d9a..c7d5c81 100644 --- a/0_meal_identification/meal_identification/environment-ci.yml +++ b/0_meal_identification/meal_identification/environment-ci.yml @@ -20,5 +20,4 @@ dependencies: - pydantic - pip: - python-dotenv - - skchange - - . \ No newline at end of file + - skchange \ No newline at end of file From f245110a86a52d14fe29abe841cb3af3f7aaf971 Mon Sep 17 00:00:00 2001 From: Tony Chan Date: Mon, 18 Nov 2024 14:27:57 -0500 Subject: [PATCH 4/5] use mamba and cache --- .github/workflows/meal_identification.yml | 105 ++++++++++++---------- 1 file changed, 60 insertions(+), 45 deletions(-) diff --git a/.github/workflows/meal_identification.yml b/.github/workflows/meal_identification.yml index cb4cd61..41afd2d 100644 --- a/.github/workflows/meal_identification.yml +++ b/.github/workflows/meal_identification.yml @@ -5,49 +5,64 @@ on: pull_request: branches: [ main ] +env: + CACHE_NUMBER: 0 + jobs: - build-linux: - runs-on: ubuntu-20.04 - defaults: - run: - working-directory: ./0_meal_identification/meal_identification - - steps: - - uses: actions/checkout@v4 - -# - name: Cache conda env -# uses: actions/cache@v3 -# with: -# path: /usr/share/miniconda/envs/meal_identification_ci -# key: conda-${{ runner.os }}-${{ hashFiles('./0_meal_identification/meal_identification/environment-ci.yml') }} - - - name: Setup Conda - uses: conda-incubator/setup-miniconda@v3 - with: - activate-environment: meal_identification_ci - environment-file: ./0_meal_identification/meal_identification/environment-ci.yml - python-version: '3.12' - auto-activate-base: false - conda-solver: classic - - - name: Install dependencies - shell: bash -l {0} - run: | - conda info - conda list - - - name: Lint with flake8 - shell: bash -l {0} - run: | - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - - name: Test with pytest - shell: bash -l {0} - run: | - pytest -v --color=yes - - - name: Package Installation Test - shell: bash -l {0} - run: | - pip install -e . \ No newline at end of file + build: + strategy: + matrix: + include: + - os: ubuntu-latest + label: linux-64 + prefix: /usr/share/miniconda3/envs/meal_identification_ci + name: ${{ matrix.label }} + runs-on: ${{ matrix.os }} + defaults: + run: + working-directory: ./0_meal_identification/meal_identification + + steps: + - uses: actions/checkout@v4 + - name: Setup Mambaforge + uses: conda-incubator/setup-miniconda@v3 + with: + miniforge-variant: Mambaforge + miniforge-version: latest + activate-environment: meal_identification_ci + use-mamba: true + + - name: Set cache date + run: echo "DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV + + - uses: actions/cache@v3 + with: + path: ${{ matrix.prefix }} + key: ${{ matrix.label }}-conda-${{ hashFiles('./0_meal_identification/meal_identification/environment-ci.yml') }}-${{ env.DATE }}-${{ env.CACHE_NUMBER }} + id: cache + + - name: Update environment + run: mamba env update -n meal_identification_ci -f environment-ci.yml + if: steps.cache.outputs.cache-hit != 'true' + + - name: Install dependencies + shell: bash -l {0} + run: | + conda info + conda list + + - name: Lint with flake8 + shell: bash -l {0} + run: | + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + + - name: Test with pytest + shell: bash -l {0} + run: | + pytest -v --color=yes + + - name: Package Installation Test + shell: bash -l {0} + run: | + pip install -e . \ No newline at end of file From 2690c9f7967d8dd5cf26ae1ef667e86c45bf36c4 Mon Sep 17 00:00:00 2001 From: Tony Chan Date: Wed, 20 Nov 2024 14:22:34 -0500 Subject: [PATCH 5/5] Update pipline script --- .github/workflows/meal_identification.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/meal_identification.yml b/.github/workflows/meal_identification.yml index 41afd2d..bee8fbb 100644 --- a/.github/workflows/meal_identification.yml +++ b/.github/workflows/meal_identification.yml @@ -27,7 +27,7 @@ jobs: - name: Setup Mambaforge uses: conda-incubator/setup-miniconda@v3 with: - miniforge-variant: Mambaforge + miniforge-variant: Miniforge3 miniforge-version: latest activate-environment: meal_identification_ci use-mamba: true