WIP #188
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: [ main ] | |
pull_request: | |
branches: [ main ] | |
# Allows running this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
build_and_test: | |
runs-on: ubuntu-latest | |
strategy: | |
# it is helpful to know which sets of tests would have succeeded, | |
# even when there is a failure. | |
fail-fast: false | |
matrix: | |
python-version: [3.9] | |
node-version: [18.x] | |
tests: | |
- ':nbrowser-^[A-G]:' | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'yarn' | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: 'pip' | |
- name: Install Python packages | |
run: | | |
pip install virtualenv | |
yarn run install:python | |
- name: Install Node.js packages | |
run: yarn install | |
- name: Build Node.js code | |
run: yarn run build:prod | |
- name: Install chromedriver | |
if: contains(matrix.tests, ':nbrowser-') | |
run: ./node_modules/selenium-webdriver/bin/linux/selenium-manager --driver chromedriver | |
- name: Run main tests without minio and redis | |
if: contains(matrix.tests, ':nbrowser-') | |
run: | | |
mkdir -p $MOCHA_WEBDRIVER_LOGDIR | |
export GREP_TESTS=$(echo $TESTS | sed "s/.*:nbrowser-\([^:]*\).*/\1/") | |
MOCHA_WEBDRIVER_SKIP_CLEANUP=1 MOCHA_WEBDRIVER_HEADLESS=1 yarn run test:nbrowser | |
env: | |
TESTS: ${{ matrix.tests }} | |
MOCHA_WEBDRIVER_LOGDIR: ${{ runner.temp }}/test-logs/webdriver | |
TESTDIR: ${{ runner.temp }}/test-logs | |
- name: Prepare for saving artifact | |
if: failure() | |
run: | | |
ARTIFACT_NAME=logs-$(echo $TESTS | sed 's/[^-a-zA-Z0-9]/_/g') | |
echo "Artifact name is '$ARTIFACT_NAME'" | |
echo "ARTIFACT_NAME=$ARTIFACT_NAME" >> $GITHUB_ENV | |
find $TESTDIR -iname "*.socket" -exec rm {} \; | |
env: | |
TESTS: ${{ matrix.tests }} | |
TESTDIR: ${{ runner.temp }}/test-logs | |
- name: Save artifacts on failure | |
if: failure() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.ARTIFACT_NAME }} | |
path: ${{ runner.temp }}/test-logs # only exists for webdriver tests | |
services: | |
# https://github.com/bitnami/bitnami-docker-minio/issues/16 | |
minio: | |
image: bitnami/minio:latest | |
env: | |
MINIO_DEFAULT_BUCKETS: "grist-docs-test:public" | |
MINIO_ROOT_USER: administrator | |
MINIO_ROOT_PASSWORD: administrator | |
ports: | |
- 9000:9000 | |
options: >- | |
--health-cmd "curl -f http://localhost:9000/minio/health/ready" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
redis: | |
image: redis | |
ports: | |
- 6379:6379 | |
options: >- | |
--health-cmd "redis-cli ping" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
candidate: | |
needs: build_and_test | |
if: ${{ success() && github.event_name == 'push' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Fetch new candidate branch | |
uses: actions/checkout@v3 | |
- name: Update candidate branch | |
uses: ad-m/github-push-action@8407731efefc0d8f72af254c74276b7a90be36e1 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: latest_candidate | |
force: true |