Merge pull request #2 from MILO-ML/feature/gh-action #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: | |
- master | |
workflow_dispatch: | |
inputs: | |
forceDockerBuild: | |
description: 'Force Docker Build' | |
required: false | |
default: 'false' | |
jobs: | |
functions: | |
if: github.ref == 'refs/heads/master' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Cache Functions Dependencies | |
id: cache_functions | |
uses: actions/cache@v3 | |
with: | |
path: functions/node_modules | |
key: ${{ runner.os }}-functions-${{ hashFiles('functions/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-functions- | |
- name: Install Dependencies | |
if: steps.cache_functions.outputs.cache-hit != 'true' | |
run: npm --prefix functions install | |
- name: Build Firebase Functions | |
run: npm --prefix functions run compile | |
- name: Create Firebase Functions Artifact | |
run: | | |
cd functions | |
zip -r ../payload.zip . | |
shell: bash | |
- name: Publish Firebase Functions Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: functions | |
path: payload.zip | |
automl: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: [3.9] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Cache Python dependencies | |
uses: actions/cache@v3 | |
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@v3 | |
with: | |
submodules: true | |
- name: Checkout Processor Tools | |
uses: actions/checkout@v3 | |
with: | |
repository: MILO-ML/Processor-Tools | |
path: preprocessor | |
- name: Set Node Version to 16 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '16' | |
- name: Install GitVersion | |
uses: gittools/actions/gitversion/[email protected] | |
with: | |
versionSpec: '5.x' | |
- name: Run GitVersion | |
id: gitversion | |
uses: gittools/actions/gitversion/[email protected] | |
with: | |
useConfigFile: false | |
- name: Update package version | |
run: | | |
sed -i.bak "s|\"version\": \"[0-9\.]*\"|\"version\": \"${{ steps.gitversion.outputs.semVer }}\"|" package.json | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Cache UI Dependencies | |
id: cache_ui | |
uses: actions/cache@v3 | |
with: | |
path: ui/node_modules | |
key: ${{ runner.os }}-ui-${{ hashFiles('ui/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-ui- | |
- name: Cache Docs Dependencies | |
id: cache_docs | |
uses: actions/cache@v3 | |
with: | |
path: docs/node_modules | |
key: ${{ runner.os }}-docs-${{ hashFiles('docs/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-docs- | |
- name: Cache Preprocessor Dependencies | |
id: cache_pp | |
uses: actions/cache@v3 | |
with: | |
path: preprocessor/node_modules | |
key: ${{ runner.os }}-preprocessor-${{ hashFiles('preprocessor/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-preprocessor- | |
- name: Install UI dependencies | |
if: steps.cache_ui.outputs.cache-hit != 'true' | |
run: npm --prefix ui install | |
- name: Install Docs dependencies | |
if: steps.cache_docs.outputs.cache-hit != 'true' | |
run: npm --prefix docs install | |
- name: Install Preprocessor dependencies | |
if: steps.cache_pp.outputs.cache-hit != 'true' | |
run: npm --prefix preprocessor install | |
- name: Build AutoML UI | |
run: npm --prefix ui run build-docker | |
- name: Build Documentation | |
run: npm --prefix docs run build | |
- name: Build Preprocessor UI | |
run: npm --prefix preprocessor run milo-build | |
- name: Create Education License | |
run: | | |
pip install requests Flask licensing | |
python sign_educational_license.py | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Set Tag | |
run: | | |
if [ "${GITHUB_REF##*/}" == "master" ]; then | |
echo "TAG=latest" >> $GITHUB_ENV | |
else | |
echo "TAG=beta" >> $GITHUB_ENV | |
fi | |
- name: Build All-in-One Docker Image | |
run: | | |
docker buildx build --platform linux/amd64,linux/arm64 \ | |
--cache-from=type=registry,ref=${{ env.ACR_ADDRESS }}/${{ env.CACHE_REPOSITORY }} \ | |
--cache-to=type=registry,ref=${{ env.ACR_ADDRESS }}/${{ env.CACHE_REPOSITORY }},mode=max \ | |
--target aio \ | |
-t ${{ env.ACR_ADDRESS }}/aio:${{ steps.gitversion.outputs.semVer }} \ | |
-t ${{ env.ACR_ADDRESS }}/aio:${{ env.TAG }} \ | |
--push \ | |
. | |
env: | |
ACR_ADDRESS: ${{ secrets.ACR_ADDRESS }} | |
CACHE_REPOSITORY: build-cache | |
- name: Build API Docker Image | |
run: | | |
docker buildx build --platform linux/amd64,linux/arm64 \ | |
--cache-from=type=registry,ref=${{ env.ACR_ADDRESS }}/${{ env.CACHE_REPOSITORY }} \ | |
--target api \ | |
-t ${{ env.ACR_ADDRESS }}/api:${{ steps.gitversion.outputs.semVer }} \ | |
-t ${{ env.ACR_ADDRESS }}/api:${{ env.TAG }} \ | |
--push \ | |
. | |
env: | |
ACR_ADDRESS: ${{ secrets.ACR_ADDRESS }} | |
CACHE_REPOSITORY: build-cache | |
- name: Build Worker Docker Image | |
run: | | |
docker buildx build --platform linux/amd64,linux/arm64 \ | |
--cache-from=type=registry,ref=${{ env.ACR_ADDRESS }}/${{ env.CACHE_REPOSITORY }} \ | |
--target worker \ | |
-t ${{ env.ACR_ADDRESS }}/worker:${{ steps.gitversion.outputs.semVer }} \ | |
-t ${{ env.ACR_ADDRESS }}/worker:${{ env.TAG }} \ | |
--push \ | |
. | |
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@v3 | |
- name: Set Node Version to 16 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '16' | |
- name: Install GitVersion | |
uses: gittools/actions/gitversion/[email protected] | |
with: | |
versionSpec: '5.x' | |
- name: Run GitVersion | |
id: gitversion | |
uses: gittools/actions/gitversion/[email protected] | |
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@v3 | |
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/static/ | |
- name: Create Firebase Artifact | |
run: | | |
cd firebase | |
zip -r ../payload.zip . | |
shell: bash | |
- name: Publish Firebase Hosting Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: static | |
path: payload.zip |