Test chill-viking/npm-ci #1796
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 confirms that the action works on all supported versions of node and OS | |
# It is not meant to be used by anyone else | |
name: Test chill-viking/npm-ci | |
on: # yamllint disable-line rule:truthy | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
types: [opened, synchronize, reopened, closed] | |
schedule: | |
- cron: "30 5,17 * * *" | |
permissions: read-all | |
concurrency: | |
group: ${{ github.ref }}-${{ github.workflow }} | |
cancel-in-progress: true | |
jobs: | |
clear-cache: | |
runs-on: ubuntu-latest | |
permissions: write-all | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: Cleanup | |
if: github.event_name == 'pull_request' | |
run: | | |
gh extension install actions/gh-actions-cache | |
REPO=${{ github.repository }} | |
echo "Fetching list of cache key" | |
cacheKeysForPR=$(gh actions-cache list -R $REPO | cut -f 1 ) | |
## Setting this to not fail the workflow while deleting cache keys. | |
set +e | |
echo "Deleting caches..." | |
for cacheKey in $cacheKeysForPR | |
do | |
gh actions-cache delete "$cacheKey" -R $REPO --confirm | |
done | |
echo "Done" | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
create-package: | |
runs-on: ubuntu-latest | |
name: init test package | |
if: github.event.action != 'closed' | |
strategy: | |
matrix: | |
node-version: [18, 20] | |
steps: | |
- name: "Use Node.js (${{ matrix.node-version }}.x)" | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }}.x | |
- name: Create test package | |
run: | | |
mkdir testing | |
cd testing | |
npm init -y | |
npm install --save @chill-viking/layout | |
rm -rf node_modules | |
- name: Upload testing as artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: test_package_node_${{ matrix.node-version }} | |
path: testing | |
prepare-action: | |
runs-on: ubuntu-latest | |
name: upload action | |
if: github.event.action != 'closed' | |
steps: | |
- name: Checkout latest version of action | |
uses: actions/checkout@v4 | |
with: | |
path: npm-ci | |
- name: Upload action as artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: npm-ci | |
path: npm-ci | |
test-action: | |
needs: | |
- create-package | |
- prepare-action | |
- clear-cache | |
name: test action | |
if: github.event.action != 'closed' | |
# create a matrix of node versions to test against | |
strategy: | |
max-parallel: 5 | |
matrix: | |
node-version: [18, 20] | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
uses: ./.github/workflows/run-action.yml | |
with: | |
node_major: ${{ matrix.node-version }} | |
runs_on: ${{ matrix.os }} |