Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend output with change status counts #18

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/filters.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error:
- not_existing_path/**/*
any:
- "**/*"
- '**/*'
31 changes: 16 additions & 15 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: "Build"
name: 'Build'
on:
push:
paths-ignore: [ '*.md' ]
paths-ignore: ['*.md']
branches:
- master

Expand All @@ -12,20 +12,21 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: volta-cli/action@v4
- run: |
pnpm install
pnpm run all
- uses: actions/checkout@v4
- uses: volta-cli/action@v4
- run: |
pnpm install
pnpm run all

self-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./
id: filter
with:
filters: '.github/filters.yml'
- name: filter-test
if: steps.filter.outputs.any != 'true' || steps.filter.outputs.error == 'true'
run: exit 1
- uses: actions/checkout@v4
- uses: ./
id: filter
with:
filters: '.github/filters.yml'

- name: filter-test
if: steps.filter.outputs.any != 'true' || steps.filter.outputs.error == 'true'
run: exit 1
198 changes: 121 additions & 77 deletions .github/workflows/pull-request-verification.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: "Pull Request Verification"
name: 'Pull Request Verification'
on:
pull_request:
paths-ignore: [ '*.md' ]
paths-ignore: ['*.md']
branches:
- master
- '**'
Expand All @@ -13,102 +13,146 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Need history for changelog generation
- uses: volta-cli/action@v4
- run: |
pnpm i
pnpm run all
# We need to make sure the checked-in `index.mjs` actually matches what we expect it to be.
- name: Compare the expected and actual dist/ directories
run: |
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build. See status below:"
git diff
exit 1
fi
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Need history for changelog generation
- uses: volta-cli/action@v4
- run: |
pnpm i
pnpm run all
# We need to make sure the checked-in `index.mjs` actually matches what we expect it to be.
- name: Compare the expected and actual dist/ directories
run: |
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build. See status below:"
git diff
exit 1
fi

test-inline:
runs-on: ubuntu-latest
permissions:
pull-requests: read
steps:
- uses: actions/checkout@v4
- uses: ./
id: filter
with:
filters: |
error:
- not_existing_path/**/*
any:
- "**/*"
- name: filter-test
if: steps.filter.outputs.any != 'true' || steps.filter.outputs.error == 'true'
run: exit 1
- name: changes-test
if: contains(fromJSON(steps.filter.outputs.changes), 'error') || !contains(fromJSON(steps.filter.outputs.changes), 'any')
run: exit 1
- uses: actions/checkout@v4

- uses: ./
id: filter
with:
filters: |
error:
- not_existing_path/**/*
any:
- "**/*"

- name: Dump output
env:
OUTPUT: ${{ toJson(steps.filter.outputs) }}
run: echo "$OUTPUT"

- name: filter-test
if: steps.filter.outputs.any != 'true' || steps.filter.outputs.error == 'true'
run: exit 1
- name: changes-test
if: contains(fromJSON(steps.filter.outputs.changes), 'error') || !contains(fromJSON(steps.filter.outputs.changes), 'any')
run: exit 1

test-external:
runs-on: ubuntu-latest
permissions:
pull-requests: read
steps:
- uses: actions/checkout@v4
- uses: ./
id: filter
with:
filters: '.github/filters.yml'
- name: filter-test
if: steps.filter.outputs.any != 'true' || steps.filter.outputs.error == 'true'
run: exit 1
- uses: actions/checkout@v4

- uses: ./
id: filter
with:
filters: '.github/filters.yml'

- name: Dump output
env:
OUTPUT: ${{ toJson(steps.filter.outputs) }}
run: echo "$OUTPUT"

- name: filter-test
if: steps.filter.outputs.any != 'true' || steps.filter.outputs.error == 'true'
run: exit 1

test-without-token:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./
id: filter
with:
token: ''
filters: '.github/filters.yml'
- name: filter-test
if: steps.filter.outputs.any != 'true' || steps.filter.outputs.error == 'true'
run: exit 1
- uses: actions/checkout@v4

- uses: ./
id: filter
with:
token: ''
filters: '.github/filters.yml'

- name: Dump output
env:
OUTPUT: ${{ toJson(steps.filter.outputs) }}
run: echo "$OUTPUT"

- name: filter-test
if: steps.filter.outputs.any != 'true' || steps.filter.outputs.error == 'true'
run: exit 1

test-wd-without-token:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
path: somewhere
- uses: ./somewhere
id: filter
with:
token: ''
working-directory: somewhere
filters: '.github/filters.yml'
- name: filter-test
if: steps.filter.outputs.any != 'true' || steps.filter.outputs.error == 'true'
run: exit 1
- uses: actions/checkout@v4
with:
path: somewhere

- uses: ./somewhere
id: filter
with:
token: ''
working-directory: somewhere
filters: '.github/filters.yml'

- name: Dump output
env:
OUTPUT: ${{ toJson(steps.filter.outputs) }}
run: echo "$OUTPUT"

- name: filter-test
if: steps.filter.outputs.any != 'true' || steps.filter.outputs.error == 'true'
run: exit 1

test-local-changes:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: echo "NEW FILE" > local
- run: git add local
- uses: ./
id: filter
with:
base: HEAD
filters: |
local:
- local
- name: filter-test
if: steps.filter.outputs.local != 'true'
run: exit 1
- name: count-test
if: steps.filter.outputs.local_count != 1
run: exit 1
- uses: actions/checkout@v4
- run: echo "NEW FILE" > local
- run: git add local

- uses: ./
id: filter
with:
base: HEAD
filters: |
local:
- local

- name: Dump output
env:
OUTPUT: ${{ toJson(steps.filter.outputs) }}
run: echo "$OUTPUT"

- name: filter-test
if: '!steps.filter.outputs.local'
run: exit 1

- name: count-test
if: steps.filter.outputs.local_count != 1
run: exit 1

- name: added-test
if: ${{ !steps.filter.outputs.local_added }}
run: exit 1

- name: modified-test
if: ${{ steps.filter.outputs.local_modified }}
run: exit 1
Loading