From b7c9333d5e691ba73cc2f542355e9e77bec6823c Mon Sep 17 00:00:00 2001 From: Samer Albahra Date: Sun, 24 Nov 2024 09:46:00 -0500 Subject: [PATCH 1/3] Fix CD workflow issues --- .github/workflows/firebase-hosting-merge.yml | 20 +++++++++++ .../firebase-hosting-pull-request.yml | 21 +++++++++++ .github/workflows/release.yaml | 36 ------------------- 3 files changed, 41 insertions(+), 36 deletions(-) create mode 100644 .github/workflows/firebase-hosting-merge.yml create mode 100644 .github/workflows/firebase-hosting-pull-request.yml delete mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/firebase-hosting-merge.yml b/.github/workflows/firebase-hosting-merge.yml new file mode 100644 index 0000000..22e2bf2 --- /dev/null +++ b/.github/workflows/firebase-hosting-merge.yml @@ -0,0 +1,20 @@ +# This file was auto-generated by the Firebase CLI +# https://github.com/firebase/firebase-tools + +name: Deploy to Firebase Hosting on merge +on: + push: + branches: + - master +jobs: + build_and_deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: npm --prefix ui install && npm --prefix ui run build + - uses: FirebaseExtended/action-hosting-deploy@v0 + with: + repoToken: ${{ secrets.GITHUB_TOKEN }} + firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_MILO_ML }} + channelId: live + projectId: milo-ml diff --git a/.github/workflows/firebase-hosting-pull-request.yml b/.github/workflows/firebase-hosting-pull-request.yml new file mode 100644 index 0000000..63d0df4 --- /dev/null +++ b/.github/workflows/firebase-hosting-pull-request.yml @@ -0,0 +1,21 @@ +# This file was auto-generated by the Firebase CLI +# https://github.com/firebase/firebase-tools + +name: Deploy to Firebase Hosting on PR +on: pull_request +permissions: + checks: write + contents: read + pull-requests: write +jobs: + build_and_preview: + if: ${{ github.event.pull_request.head.repo.full_name == github.repository }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: npm --prefix ui install && npm --prefix ui run build + - uses: FirebaseExtended/action-hosting-deploy@v0 + with: + repoToken: ${{ secrets.GITHUB_TOKEN }} + firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_MILO_ML }} + projectId: milo-ml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml deleted file mode 100644 index 32b235a..0000000 --- a/.github/workflows/release.yaml +++ /dev/null @@ -1,36 +0,0 @@ -name: CD - -on: - workflow_run: - workflows: ["CI"] - types: - - completed - -jobs: - deploy: - if: ${{ github.event.workflow_run.conclusion == 'success' }} - runs-on: ubuntu-latest - steps: - - name: Download Hosting Artifact - uses: actions/download-artifact@v4 - with: - name: static - run-id: ${{ github.event.workflow_run.id }} - github-token: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract Hosting Files - run: unzip -o payload.zip -d . - - - name: Install Node.js - uses: actions/setup-node@v4 - with: - node-version: '20' - - - name: Install Firebase CLI - run: npm install -g firebase-tools - - - name: Deploy to Firebase - env: - GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} - run: | - firebase deploy --project milo-ml --message "Release: ${{ github.run_number }}" From ac2d04b4cb7abd56229961867b96a135576dea79 Mon Sep 17 00:00:00 2001 From: Samer Albahra Date: Mon, 25 Nov 2024 20:50:16 -0500 Subject: [PATCH 2/3] Update to the latest preprocessor --- preprocessor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/preprocessor b/preprocessor index e3210e4..7f5084c 160000 --- a/preprocessor +++ b/preprocessor @@ -1 +1 @@ -Subproject commit e3210e4795dd0957ca0f2d176cec859833d98c22 +Subproject commit 7f5084c90292397c0a24c9694cdbec46738e8623 From a9e998ed8b5ca22a2a5c69b5852b3a50221842d3 Mon Sep 17 00:00:00 2001 From: Samer Albahra Date: Mon, 25 Nov 2024 21:00:59 -0500 Subject: [PATCH 3/3] Update pipelines to clean up --- .../{build.yaml => docker-hub-merge.yaml} | 114 +----------------- .github/workflows/firebase-hosting-merge.yml | 35 +++++- .../firebase-hosting-pull-request.yml | 35 +++++- .github/workflows/python-unit-tests.yml | 41 +++++++ 4 files changed, 110 insertions(+), 115 deletions(-) rename .github/workflows/{build.yaml => docker-hub-merge.yaml} (60%) create mode 100644 .github/workflows/python-unit-tests.yml diff --git a/.github/workflows/build.yaml b/.github/workflows/docker-hub-merge.yaml similarity index 60% rename from .github/workflows/build.yaml rename to .github/workflows/docker-hub-merge.yaml index c22b759..cfd9a58 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/docker-hub-merge.yaml @@ -1,51 +1,12 @@ -name: CI +name: Deploy to Docker Hub on merge on: push: branches: - master - workflow_dispatch: - inputs: - forceDockerBuild: - description: 'Force Docker Build' - required: false - default: 'false' jobs: - automl: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: [3.9] - steps: - - uses: actions/checkout@v4 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - - name: Cache Python dependencies - uses: actions/cache@v4 - id: python_cache - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - - - name: Run tests - run: | - pip install pytest - pytest - docker: - if: ${{ success() && ( (github.event_name == 'workflow_dispatch' && github.event.inputs.forceDockerBuild == 'true') || github.ref == 'refs/heads/master') }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -59,11 +20,6 @@ jobs: repository: MILO-ML/Processor-Tools path: preprocessor - - name: Set Node Version to 20 - uses: actions/setup-node@v4 - with: - node-version: '20' - - name: Install GitVersion uses: gittools/actions/gitversion/setup@v3.0.0 with: @@ -186,71 +142,3 @@ jobs: env: ACR_ADDRESS: ${{ secrets.ACR_ADDRESS }} CACHE_REPOSITORY: build-cache - - authapp: - if: ${{ success() && github.ref == 'refs/heads/master' }} - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Set Node Version to 20 - uses: actions/setup-node@v4 - with: - node-version: '20' - - - name: Install GitVersion - uses: gittools/actions/gitversion/setup@v3.0.0 - with: - versionSpec: '5.x' - - - name: Run GitVersion - id: gitversion - uses: gittools/actions/gitversion/execute@v3.0.0 - with: - useConfigFile: false - - - name: Update package version - run: | - sed -i.bak "s|\"version\": \"[0-9\.]*\"|\"version\": \"${{ steps.gitversion.outputs.semVer }}\"|" package.json - - - name: Cache UI Dependencies - id: cache_ui - uses: actions/cache@v4 - with: - path: ui/node_modules - key: ${{ runner.os }}-ui-${{ hashFiles('ui/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-ui- - - - name: Install UI dependencies - if: steps.cache_ui.outputs.cache-hit != 'true' - run: npm --prefix ui install - - - name: Build AutoML UI - run: npm --prefix ui run build - - - name: Prepare staging directory - run: mkdir -p firebase - - - name: Copy Firebase Configuration to Staging - run: | - cp firebase.json firebase/ - cp firestore.rules firebase/ - cp firestore.indexes.json firebase/ - - - name: Copy Front-End to Staging - run: cp -r static firebase/ - - - name: Create Firebase Artifact - run: | - cd firebase - zip -r ../payload.zip . - shell: bash - - - name: Publish Firebase Hosting Artifact - uses: actions/upload-artifact@v4 - with: - name: static - path: payload.zip diff --git a/.github/workflows/firebase-hosting-merge.yml b/.github/workflows/firebase-hosting-merge.yml index 22e2bf2..d57e1d9 100644 --- a/.github/workflows/firebase-hosting-merge.yml +++ b/.github/workflows/firebase-hosting-merge.yml @@ -11,7 +11,40 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - run: npm --prefix ui install && npm --prefix ui run build + with: + fetch-depth: 0 + + - name: Install GitVersion + uses: gittools/actions/gitversion/setup@v3.0.0 + with: + versionSpec: '5.x' + + - name: Run GitVersion + id: gitversion + uses: gittools/actions/gitversion/execute@v3.0.0 + with: + useConfigFile: false + + - name: Update package version + run: | + sed -i.bak "s|\"version\": \"[0-9\.]*\"|\"version\": \"${{ steps.gitversion.outputs.semVer }}\"|" package.json + + - name: Cache UI Dependencies + id: cache_ui + uses: actions/cache@v4 + with: + path: ui/node_modules + key: ${{ runner.os }}-ui-${{ hashFiles('ui/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-ui- + + - name: Install UI dependencies + if: steps.cache_ui.outputs.cache-hit != 'true' + run: npm --prefix ui install + + - name: Build AutoML UI + run: npm --prefix ui run build + - uses: FirebaseExtended/action-hosting-deploy@v0 with: repoToken: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/firebase-hosting-pull-request.yml b/.github/workflows/firebase-hosting-pull-request.yml index 63d0df4..253b406 100644 --- a/.github/workflows/firebase-hosting-pull-request.yml +++ b/.github/workflows/firebase-hosting-pull-request.yml @@ -13,7 +13,40 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - run: npm --prefix ui install && npm --prefix ui run build + with: + fetch-depth: 0 + + - name: Install GitVersion + uses: gittools/actions/gitversion/setup@v3.0.0 + with: + versionSpec: '5.x' + + - name: Run GitVersion + id: gitversion + uses: gittools/actions/gitversion/execute@v3.0.0 + with: + useConfigFile: false + + - name: Update package version + run: | + sed -i.bak "s|\"version\": \"[0-9\.]*\"|\"version\": \"${{ steps.gitversion.outputs.semVer }}\"|" package.json + + - name: Cache UI Dependencies + id: cache_ui + uses: actions/cache@v4 + with: + path: ui/node_modules + key: ${{ runner.os }}-ui-${{ hashFiles('ui/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-ui- + + - name: Install UI dependencies + if: steps.cache_ui.outputs.cache-hit != 'true' + run: npm --prefix ui install + + - name: Build AutoML UI + run: npm --prefix ui run build + - uses: FirebaseExtended/action-hosting-deploy@v0 with: repoToken: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/python-unit-tests.yml b/.github/workflows/python-unit-tests.yml new file mode 100644 index 0000000..5f6c42b --- /dev/null +++ b/.github/workflows/python-unit-tests.yml @@ -0,0 +1,41 @@ +name: Python Unit Tests + +on: + push: + branches: + - master + +jobs: + automl: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.9] + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Cache Python dependencies + uses: actions/cache@v4 + id: python_cache + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + + - name: Run tests + run: | + pip install pytest + pytest