Fixes #1087 #3535
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: | |
# Triggers the workflow on push or pull request events | |
push: | |
pull_request: | |
release: | |
tags: | |
- 'v*' | |
types: [published] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
Server_tests: | |
name: Server tests | |
runs-on: ubuntu-latest | |
# Test different python versions | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ['3.9', '3.10', '3.11'] | |
services: | |
# How to use MySQL | |
mysql: | |
image: mysql:5.7 | |
env: | |
MYSQL_ROOT_PASSWORD: root | |
ports: | |
- 3306:3306 | |
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
redis: | |
# Docker Hub image | |
image: redis | |
# Set health checks to wait until redis has started | |
options: >- | |
--health-cmd "redis-cli ping" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
# Maps port 6379 on service container to the host | |
- 6379:6379 | |
steps: | |
- name: Setup mysql server | |
run: > | |
mysql -uroot -proot -h127.0.0.1 -e " | |
DROP DATABASE IF EXISTS sbs_test; | |
CREATE DATABASE IF NOT EXISTS sbs_test DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_unicode_ci; | |
CREATE USER 'sbs'@'%' IDENTIFIED BY 'sbs'; | |
GRANT ALL PRIVILEGES ON *.* TO 'sbs'@'%' WITH GRANT OPTION; | |
" | |
- name: Install SAML2 dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y libxml2-dev libxmlsec1-dev | |
# Run Checkout code | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: 'pip' | |
cache-dependency-path: 'server/requirements/*.txt' | |
- name: Display Python version | |
run: | | |
python -c "import sys; print(sys.version)" | |
echo coverage: .${{ matrix.coverage }}. | |
- name: Install dependencies | |
run: | | |
python -m pip install pip setuptools wheel | |
pip install --upgrade pip | |
pip install -r ./server/requirements/test.txt | |
pip install flake8 | |
# Setup tmate session | |
#- name: Setup tmate session | |
# uses: mxschmitt/action-tmate@v3 | |
- name: Run flake8 | |
run: | | |
cd ./server | |
flake8 . | |
- name: Run tests with coverage | |
run: | | |
cd ./server | |
coverage run -m pytest test --cov-report xml --cov=server | |
timeout-minutes: 20 | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v3 | |
if: success() | |
Client_build: | |
name: Client build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Run errands | |
run: | | |
sudo apt -y install curl | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Get yarn cache directory path | |
id: yarn-cache-dir-path | |
run: echo "DIR=$(yarn cache dir)" >> $GITHUB_OUTPUT | |
- uses: actions/cache@v3 | |
id: yarn-cache | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.DIR }} | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn- | |
- name: Use Node.js 16 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "16.20.0" | |
# node-version: "16.10.0" | |
cache: "yarn" | |
cache-dependency-path: '**/yarn.lock' | |
- name: Install dependencies | |
shell: bash | |
run: | | |
source ~/.nvm/nvm.sh | |
rm -rf ~/.yarn | |
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.22.19 | |
export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH" | |
yarn -v | |
# nvm install "16.10.0" | |
# nvm use "16.10.0" | |
env: | |
VNM_DIR: ~/.nvm | |
- name: Run tests | |
shell: bash | |
run: | | |
cd client | |
yarn install | |
yarn test | |
yarn build | |
env: | |
CI: true | |
VNM_DIR: ~/.nvm | |
INLINE_RUNTIME_CHUNK: False | |
IMAGE_INLINE_SIZE_LIMIT: 0 | |
timeout-minutes: 15 | |
#- name: Setup tmate session | |
# uses: mxschmitt/action-tmate@v3 | |
- name: Save version info | |
run: | | |
git log -1 > ./server/api/git.info | |
- name: Create build file | |
run: | | |
tar -cJ -f /tmp/sbs.tar.xz \ | |
--transform 's,^\./,sbs/,' --sort=name \ | |
--owner=0 --group=0 --mode=u=rwX,go=rX \ | |
--exclude=./client/node_modules --exclude=./.git \ | |
. | |
- name: Show what we are shipping | |
run: | | |
tar tvJf /tmp/sbs.tar.xz | |
- name: Create Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: "sbs-build" | |
path: "/tmp/sbs.tar.xz" | |
Artifact_upload: | |
name: Create release | |
if: > | |
github.actor!='dependabot[bot]' && | |
github.event_name!='pull_request' && | |
( github.ref_type=='tag' || github.ref_type=='branch' ) | |
needs: | |
- "Client_build" | |
- "Server_tests" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Fetch build | |
id: fetch_artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: "sbs-build" | |
path: "artifacts/" | |
- name: Info | |
run: | | |
ls -la ${{steps.fetch_artifact.outputs.download-path}} | |
sha1sum ${{steps.fetch_artifact.outputs.download-path}}/* || true | |
sha256sum ${{steps.fetch_artifact.outputs.download-path}}/* || true | |
- name: Create Release | |
if: "github.ref_type=='tag'" | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: "${{steps.fetch_artifact.outputs.download-path}}/*" | |
- name: Advance latest tag | |
if: "github.ref_type=='branch'" | |
uses: EndBug/latest-tag@v1 | |
with: | |
ref: "branch+${{github.ref_name}}" | |
description: "Latest commit in branch ${{github.ref_name}}" | |
- name: remove all previous "latest" releases | |
if: "github.ref_type=='branch'" | |
uses: dev-drprasad/[email protected] | |
with: | |
keep_latest: 0 | |
delete_tag_pattern: "branch+${{github.ref_name}}" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create Release for main/latest | |
if: "github.ref_type=='branch'" | |
uses: softprops/action-gh-release@v1 | |
with: | |
name: "Latest from branch ${{github.ref_name}}" | |
tag_name: "branch+${{github.ref_name}}" | |
prerelease: true | |
files: "${{steps.fetch_artifact.outputs.download-path}}/sbs.tar.xz" | |
- name: Get token | |
id: get_token | |
uses: machine-learning-apps/actions-app-token@master | |
with: | |
APP_PEM: ${{ secrets.SRAM_ACTIONAPP_PEM }} | |
APP_ID: ${{ secrets.SRAM_ACTIONAPP_APPID }} | |
- name: Test new SBS build in SCZ-deploy's CI-runner | |
if: "github.ref_name=='main'" | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ steps.get_token.outputs.app_token }} | |
script: | | |
await github.rest.actions.createWorkflowDispatch({ | |
owner: 'SURFscz', | |
repo: 'SRAM-deploy', | |
workflow_id: 'ci-runner.yml', | |
ref: 'main' | |
}) | |