Bump actions/setup-node from 3 to 4 #150
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: | |
workflow_dispatch: | |
permissions: | |
packages: read | |
jobs: | |
automated_tests: | |
name: Unit & integration tests | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup NodeJS | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
cache: 'npm' | |
- name: Install deps | |
run: npm ci | |
- name: Run tests | |
run: npm test -- --coverage | |
- name: Build | |
run: npm run build | |
- name: Clear node modules | |
run: rm -rf node_modules/ | |
- name: (Backward compatibility) Should prune untagged versions | |
uses: ./ # Itself | |
id: legacy_test_prune_untagged | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
user: vlaurin | |
container: test-action-ghcr-prune | |
dry-run: true | |
untagged: true | |
keep-last: 1 | |
- name: (Backward compatibility) Expect 2 untagged versions to be pruned | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const actualCount = ${{ steps.legacy_test_prune_untagged.outputs.count }}; | |
const expectedCount = 2; | |
if (actualCount !== expectedCount) { | |
core.setFailed(`Expected ${expectedCount} versions to be pruned but was: ${actualCount}`) | |
} | |
const actualPruned = '${{ steps.legacy_test_prune_untagged.outputs.prunedVersionIds }}'; | |
const expectedPruned = '[15452193,15452086]'; | |
if (actualPruned !== expectedPruned) { | |
core.setFailed(`Expected ${expectedPruned} to be pruned but was: ${actualPruned}`) | |
} | |
- name: (Backward compatibility) Should prune tagged versions without exclusions | |
uses: ./ # Itself | |
id: legacy_test_prune_tagged | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
user: vlaurin | |
container: test-action-ghcr-prune | |
dry-run: true | |
tag-regex: ^pr- | |
keep-tags: | | |
pr-demo | |
- name: (Backward compatibility) Expect 3 tagged versions to be pruned | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const actualCount = ${{ steps.legacy_test_prune_tagged.outputs.count }}; | |
const expectedCount = 3; | |
if (actualCount !== expectedCount) { | |
core.setFailed(`Expected ${expectedCount} versions to be pruned but was: ${actualCount}`) | |
} | |
const actualPruned = '${{ steps.legacy_test_prune_tagged.outputs.prunedVersionIds }}'; | |
const expectedPruned = '[15452486,15452460,15452388]'; | |
if (actualPruned !== expectedPruned) { | |
core.setFailed(`Expected ${expectedPruned} to be pruned but was: ${actualPruned}`) | |
} | |
- name: (Backward compatibility) Should prune tagged versions without RegEx exclusions | |
uses: ./ # Itself | |
id: legacy_test_prune_tagged_keep_tags_regexes | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
user: vlaurin | |
container: test-action-ghcr-prune | |
dry-run: true | |
tag-regex: ^pr- | |
keep-tags-regexes: | | |
^pr-[a-z]+ | |
^pr-\d\d2 | |
- name: (Backward compatibility) Expect 2 tagged versions to be pruned | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const actualCount = ${{ steps.legacy_test_prune_tagged_keep_tags_regexes.outputs.count }}; | |
const expectedCount = 2; | |
if (actualCount !== expectedCount) { | |
core.setFailed(`Expected ${expectedCount} versions to be pruned but was: ${actualCount}`) | |
} | |
const actualPruned = '${{ steps.legacy_test_prune_tagged_keep_tags_regexes.outputs.prunedVersionIds }}'; | |
const expectedPruned = '[15452486,15452388]'; | |
if (actualPruned !== expectedPruned) { | |
core.setFailed(`Expected ${expectedPruned} to be pruned but was: ${actualPruned}`) | |
} | |
- name: Should prune untagged versions | |
uses: ./ # Itself | |
id: test_prune_untagged | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
user: vlaurin | |
container: test-action-ghcr-prune | |
dry-run: true | |
prune-untagged: true | |
keep-last: 1 | |
- name: Expect 2 untagged versions to be pruned | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const actualCount = ${{ steps.test_prune_untagged.outputs.count }}; | |
const expectedCount = 2; | |
if (actualCount !== expectedCount) { | |
core.setFailed(`Expected ${expectedCount} versions to be pruned but was: ${actualCount}`) | |
} | |
const actualPruned = '${{ steps.test_prune_untagged.outputs.prunedVersionIds }}'; | |
const expectedPruned = '[15452193,15452086]'; | |
if (actualPruned !== expectedPruned) { | |
core.setFailed(`Expected ${expectedPruned} to be pruned but was: ${actualPruned}`) | |
} | |
- name: Should prune tagged versions without exclusions | |
uses: ./ # Itself | |
id: test_prune_tagged | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
user: vlaurin | |
container: test-action-ghcr-prune | |
dry-run: true | |
prune-tags-regexes: ^pr- | |
keep-tags: | | |
pr-demo | |
- name: Expect 3 tagged versions to be pruned | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const actualCount = ${{ steps.test_prune_tagged.outputs.count }}; | |
const expectedCount = 3; | |
if (actualCount !== expectedCount) { | |
core.setFailed(`Expected ${expectedCount} versions to be pruned but was: ${actualCount}`) | |
} | |
const actualPruned = '${{ steps.test_prune_tagged.outputs.prunedVersionIds }}'; | |
const expectedPruned = '[15452486,15452460,15452388]'; | |
if (actualPruned !== expectedPruned) { | |
core.setFailed(`Expected ${expectedPruned} to be pruned but was: ${actualPruned}`) | |
} | |
- name: Should prune tagged versions without RegEx exclusions | |
uses: ./ # Itself | |
id: test_prune_tagged_keep_tags_regexes | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
user: vlaurin | |
container: test-action-ghcr-prune | |
dry-run: true | |
prune-tags-regexes: ^pr- | |
keep-tags-regexes: | | |
^pr-[a-z]+ | |
^pr-\d\d2 | |
- name: Expect 2 tagged versions to be pruned | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const actualCount = ${{ steps.test_prune_tagged_keep_tags_regexes.outputs.count }}; | |
const expectedCount = 2; | |
if (actualCount !== expectedCount) { | |
core.setFailed(`Expected ${expectedCount} versions to be pruned but was: ${actualCount}`) | |
} | |
const actualPruned = '${{ steps.test_prune_tagged_keep_tags_regexes.outputs.prunedVersionIds }}'; | |
const expectedPruned = '[15452486,15452388]'; | |
if (actualPruned !== expectedPruned) { | |
core.setFailed(`Expected ${expectedPruned} to be pruned but was: ${actualPruned}`) | |
} | |
- name: Should prune tagged versions from many regexes | |
uses: ./ # Itself | |
id: test_prune_many_tags_regexes | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
user: vlaurin | |
container: test-action-ghcr-prune | |
dry-run: true | |
prune-tags-regexes: | | |
^pr-[a-z]+$ | |
^pr-\d{3}$ | |
keep-tags-regexes: 2$ | |
- name: Expect 3 tagged versions to be pruned | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const actualCount = ${{ steps.test_prune_many_tags_regexes.outputs.count }}; | |
const expectedCount = 3; | |
if (actualCount !== expectedCount) { | |
core.setFailed(`Expected ${expectedCount} versions to be pruned but was: ${actualCount}`) | |
} | |
const actualPruned = '${{ steps.test_prune_many_tags_regexes.outputs.prunedVersionIds }}'; | |
const expectedPruned = '[15452525,15452486,15452388]'; | |
if (actualPruned !== expectedPruned) { | |
core.setFailed(`Expected ${expectedPruned} to be pruned but was: ${actualPruned}`) | |
} |