chore(workflows/tests): change cache to use "runs-on" instead of "nod… #1131
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
# 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: Node.js CI | |
on: | |
push: | |
pull_request: | |
workflow_dispatch: | |
inputs: | |
git-ref: | |
description: Git Ref (Optional) | |
required: false | |
jobs: | |
tests: | |
runs-on: ${{ matrix.distro }} | |
strategy: | |
matrix: | |
# this is a hack as there is currently no (public) way to access "runs-on" with version | |
distro: [ubuntu-22.04] | |
node-version: [14.x, 16.x, 18.x, 20.x, 22.x] | |
steps: | |
- uses: actions/checkout@v4 | |
if: github.event.inputs.git-ref == '' | |
with: | |
fetch-depth: 0 # always fetch everything to be sure for codecov | |
- uses: actions/checkout@v4 | |
if: github.event.inputs.git-ref != '' | |
with: | |
ref: ${{ github.event.inputs.git-ref }} | |
fetch-depth: 5 # because this is an manual trigger, only fetch the latest 5 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Load MongoDB binary cache | |
id: cache-mongodb-binaries | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/mongodb-binaries | |
key: ${{ matrix.distro }}-${{ hashFiles('**/globalSetup.ts') }} | |
restore-keys: | | |
${{ matrix.distro }}- | |
${{ matrix.distro }} | |
- name: Install node_modules | |
run: yarn | |
- name: TSCheck | |
run: yarn --cwd packages/mongodb-memory-server-core run tscheck | |
- name: ESLint | |
run: yarn run lint | |
- name: Tests | |
run: yarn --cwd packages/mongodb-memory-server-core run coverage --colors | |
env: | |
CI: true | |
- name: Send codecov.io stats | |
if: matrix.node-version == '14.x' | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
publish: | |
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/beta' || startsWith(github.ref, 'refs/heads/old') | |
needs: [tests] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js 18 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18.x | |
- name: Install node_modules | |
run: yarn install | |
- name: Build | |
run: yarn build | |
- name: Semantic Release | |
uses: cycjimmy/semantic-release-action@cb425203a562475bca039ba4dbf90c7f9ac790f4 # v4.1.0 | |
with: | |
# dry_run: true | |
# using semantic-release 23.x because of https://github.com/semantic-release/release-notes-generator/issues/675 | |
extra_plugins: | | |
@semantic-release/git@10.x | |
@semantic-release/changelog@6.x | |
@semantic-release/commit-analyzer@13.x | |
@semantic-release/release-notes-generator@14.x | |
@semantic-release/github@10.x | |
@semantic-release/npm@12.x | |
@commitlint/config-conventional@19.x | |
semantic-release-replace-plugin@1.2.7 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |