Bump actions/download-artifact from 2 to 4.1.7 in /.github/workflows #671
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
# SPDX-FileCopyrightText: 2021 Anders Rune Jensen | |
# | |
# SPDX-License-Identifier: Unlicense | |
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | |
name: CI | |
on: | |
push: | |
branches: [master] | |
pull_request: | |
branches: [master] | |
jobs: | |
licenses: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: REUSE Compliance Check | |
uses: fsfe/reuse-action@v1 | |
test: | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
strategy: | |
matrix: | |
node-version: [16.x] | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v1 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- run: npm install | |
- name: npm test | |
run: DEBUG=jitdb npm test | |
prepare_for_benchmarks: | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Use Node.js 16.x | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 16.x | |
- run: npm install | |
- id: set-matrix | |
run: | | |
echo "getting benchmark matrix" | |
BENCHMARKS=$(npm run --silent get-benchmark-matrix) | |
echo "checking benchmark matrix" | |
if [ -z "$BENCHMARKS" ]; then | |
echo "Failed to generate benchmarks" | |
exit 1 | |
else | |
echo $BENCHMARKS | |
echo "::set-output name=matrix::{\"benchmark\":$BENCHMARKS}" | |
fi | |
- name: Restore Benchmark Fixture Cache | |
id: benchmark-fixture-cache | |
uses: actions/cache@v2 | |
env: | |
cache-name: cache-benchmark-fixture | |
with: | |
path: /tmp/jitdb-benchmark | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json','**/package.json','**/benchmark/**/*.js','**/.github/**/*') }} | |
- name: Generate Benchmark Fixture | |
if: steps.benchmark-fixture-cache.outputs.cache-hit != 'true' | |
run: npm run benchmark-only-create | |
- name: Upload Benchmark Fixture | |
uses: actions/upload-artifact@v2 | |
with: | |
name: benchmark-fixture | |
path: /tmp/jitdb-benchmark | |
retention-days: 1 | |
benchmark: | |
needs: | |
- test | |
- prepare_for_benchmarks | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: ${{ fromJson(needs.prepare_for_benchmarks.outputs.matrix) }} | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Use Node.js 16.x | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 16.x | |
- run: npm install | |
- name: Download Benchmark Fixture | |
uses: actions/[email protected] | |
with: | |
name: benchmark-fixture | |
path: /tmp/jitdb-benchmark | |
- name: Benchmark | |
run: BENCHMARK_DURATION_MS=60000 CURRENT_BENCHMARK="${{matrix.benchmark}}" npm run benchmark | |
- name: Upload Result | |
uses: actions/upload-artifact@v2 | |
with: | |
name: ${{matrix.benchmark}}-md | |
path: /tmp/jitdb-benchmark/benchmark.md | |
retention-days: 1 | |
benchmark_results: | |
needs: benchmark | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download Results | |
uses: actions/[email protected] | |
with: | |
path: /tmp/artifacts | |
- id: get-comment-body | |
name: Gather results | |
run: | | |
body=$(cat /tmp/artifacts/*-md/* | awk '!x[$0]++') | |
headLineCount=$(printf "$body" | grep -hn '\--' | cut -f1 -d:) | |
totalLineCount=$(printf "$body" | wc -l | cut -f1 -d" ") | |
headLines=$(printf "$body" | head -n $headLineCount) | |
sortedTailLines=$(printf "$body" | tail -n $(($totalLineCount - $headLineCount + 1)) | sort) | |
body=$(printf "$headLines\n$sortedTailLines") | |
body="${body//'%'/'%25'}" | |
body="${body//$'\n'/'%0A'}" | |
body="${body//$'\r'/'%0D'}" | |
echo ::set-output name=body::$body | |
- name: Publish comment | |
uses: mshick/add-pr-comment@v1 | |
continue-on-error: true | |
with: | |
message: ${{ steps.get-comment-body.outputs.body }} | |
repo-token: ${{ secrets.GITHUB_TOKEN }} |