Skip to content

Commit

Permalink
enh(ci): Use cascading jobs to save time
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
  • Loading branch information
marcelklehr committed Dec 7, 2023
1 parent 65d1a00 commit 512bef6
Showing 1 changed file with 68 additions and 30 deletions.
98 changes: 68 additions & 30 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,58 @@ concurrency:
cancel-in-progress: true

jobs:
php:
init:
runs-on: ubuntu-latest

strategy:
# do not stop on another job's failure
fail-fast: false
matrix:
node-version: [ 20.x ]
npm-version: [ 10.x ]

steps:
- name: Checkout floccus
uses: actions/checkout@v2
with:
path: floccus

- name: Set up node ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Set up npm ${{ matrix.npm-version }}
run: npm i -g npm@"${{ matrix.npm-version }}"

- name: Cache node modules
uses: actions/cache@v1
env:
cache-name: cache-node-modules
with:
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install dependencies & build
working-directory: floccus
run: |
npm ci
npm run build-release --if-present
- name: Save context
uses: buildjet/cache/save@v3
with:
key: selenium-context-${{ github.run_id }}
path: ./

selenium:
runs-on: ubuntu-latest
needs: init

env:
SELENIUM_HUB_HOST: hub
TEST_HOST: nextcloud
Expand Down Expand Up @@ -129,10 +178,13 @@ jobs:
MYSQL_ROOT_PASSWORD: ${{env.MYSQL_PASSWORD}}

steps:
- name: Checkout floccus
uses: actions/checkout@v2

- name: Restore context
uses: buildjet/cache/restore@v3
with:
path: floccus
fail-on-cache-miss: true
key: selenium-context-${{ github.run_id }}
path: ./

- name: Checkout bookmarks app
uses: actions/checkout@v2
Expand Down Expand Up @@ -169,32 +221,6 @@ jobs:
[ $NEXT_WAIT_TIME -lt 25 ]
if: matrix.floccus-adapter != 'fake'

- name: Set up node ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Set up npm ${{ matrix.npm-version }}
run: npm i -g npm@"${{ matrix.npm-version }}"

- name: Cache node modules
uses: actions/cache@v1
env:
cache-name: cache-node-modules
with:
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install dependencies & build
working-directory: floccus
run: |
npm ci
npm run build-release --if-present
- name: Wait for Selenium
run: |
sudo apt install -y jq
Expand All @@ -216,3 +242,15 @@ jobs:
APP_VERSION: ${{ matrix.app-version }}
run: |
npm run test
summary:
runs-on: ubuntu-latest
needs: [ init, selenium ]

if: always()

name: selenium-summary

steps:
- name: Summary status
run: if ${{ needs.init.result != 'success' || ( needs.selenium.result != 'success' && needs.selenium.result != 'skipped' ) }}; then exit 1; fi

0 comments on commit 512bef6

Please sign in to comment.