Skip to content

Commit

Permalink
feat!: Use locally installed git to determine file changes. (#1596)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason3S committed Feb 29, 2024
1 parent 3fcea60 commit 5d97173
Show file tree
Hide file tree
Showing 37 changed files with 12,096 additions and 13,660 deletions.
55 changes: 47 additions & 8 deletions .github/workflows/smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Smoke Test Context
on: # rebuild any PRs and main branch changes
pull_request:
push:
issues:
issue_comment:
workflow_dispatch:

permissions:
Expand All @@ -12,18 +14,55 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Get Environment
id: get-env
uses: actions/github-script@v7
with:
script: |
return process.env;
- name: View context attributes
uses: actions/github-script@v7
with:
result-encoding: string
script: |
console.log('Env %o', process.env);
console.log('context: %o', context);
return process.env.GITHUB_EVENT_PATH;
- name: Read Event File
id: read-event
uses: streetsidesoftware/actions/public/read-file@v1
with:
path: ${{ fromJSON(steps.get-env.outputs.result).GITHUB_EVENT_PATH }}

- name: View context in summary
uses: streetsidesoftware/actions/public/summary@v1
with:
text: |
Context:
# Context Summary
Event Name: `${{ github.event_name }}`
After: `${{ github.event.after }}`
Before: `${{ github.event.before }}`
PR Base SHA: `${{ github.event.pull_request.base.sha }}`
Commits Ids:
```
${{ toJSON(github.event.commits.*.id || 'undefined') }}
```
Env:
`````json
${{ toJson(fromJson(steps.get-env.outputs.result)) }}
`````
GitHub Context:
`````json
${{ toJson(github) }}
`````
- name: View context attributes
uses: actions/github-script@v7
with:
script: |
console.log(context);
console.log('%o', context);
console.log(JSON.stringify(context, null, 2));
Event File:
`````json
${{ toJson(fromJSON(steps.read-event.outputs.result)) }}
`````
102 changes: 55 additions & 47 deletions .github/workflows/test-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ name: "test-action"
on: # rebuild any PRs and main branch changes
pull_request:
push:
branches:
- main

permissions:
contents: read

env:
FETCH_DEPTH: 1

jobs:
test-action: # run the action
runs-on: ubuntu-latest
Expand All @@ -17,11 +18,26 @@ jobs:
id: cspell-action
env:
TEST: true
- name: Show Results
uses: streetsidesoftware/actions/public/summary@v1
with:
text: |
outputs:
``````json
${{ toJSON(steps.cspell-action.outputs) }}
``````
Commits Ids:
```
${{ toJSON(github.event.commits.*.id || 'undefined') }}
```
test-action-with-file: # run the action
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: ${{ env.FETCH_DEPTH }}
- uses: ./
id: cspell-action
env:
Expand All @@ -30,30 +46,44 @@ jobs:
files: |
**/*.ts
**/*.md
- name: Show Results
uses: streetsidesoftware/actions/public/summary@v1
with:
text: |
outputs:
``````json
${{ toJSON(steps.cspell-action.outputs) }}
``````
test-action-no-increment: # run the action
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: ${{ env.FETCH_DEPTH }}
- uses: ./
id: cspell-action
env:
TEST: true
with:
incremental_files_only: false
files: |
**
.*/**
.
- name: Show Results
env:
outputs: ${{ toJSON(steps.cspell-action.outputs) }}
run: |
echo "$outputs"
uses: streetsidesoftware/actions/public/summary@v1
with:
text: |
outputs:
``````json
${{ toJSON(steps.cspell-action.outputs) }}
``````
test-action-no-increment-verbose: # run the action
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: ${{ env.FETCH_DEPTH }}
- uses: ./
id: cspell-action
with:
Expand All @@ -62,11 +92,21 @@ jobs:
**
.*/**
verbose: true
- name: Show Results
uses: streetsidesoftware/actions/public/summary@v1
with:
text: |
outputs:
``````json
${{ toJSON(steps.cspell-action.outputs) }}
``````
test-action-files-with-issues: # run the action
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: ${{ env.FETCH_DEPTH }}
- uses: ./
id: cspell-action
with:
Expand All @@ -77,42 +117,10 @@ jobs:
strict: false
inline: none
- name: Show Results
env:
outputs: ${{ toJSON(steps.cspell-action.outputs) }}
run: |
echo "$outputs"
# Experiment with writing the status to a PR.
# show_status:
# runs-on: ubuntu-latest
# steps:
# - name: Env
# env:
# github: ${{ toJSON(github) }}
# run: |
# echo GITHUB_REPOSITORY_OWNER=$GITHUB_REPOSITORY_OWNER
# echo GITHUB_REPOSITORY=$GITHUB_REPOSITORY
# echo GITHUB_REF=$GITHUB_REF
# echo SHA=${{ github.event.pull_request.head.sha || env.GITHUB_SHA }}
# echo github="$github"
# env
# - name: GH Status
# env:
# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# run: |
# gh api \
# -H "Accept: application/vnd.github+json" \
# /repos/$GITHUB_REPOSITORY/commits/$GITHUB_REF/statuses
# - name: Write Status
# env:
# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# SHA: ${{ github.event.pull_request.head.sha || env.GITHUB_SHA }}
# run: |
# gh api \
# --method POST \
# -H "Accept: application/vnd.github+json" \
# /repos/$GITHUB_REPOSITORY/statuses/$SHA \
# -f state='success' \
# -f target_url='https://example.com/build/status' \
# -f description='The test succeeded!' \
# -f context='continuous-integration/testing for fun'
uses: streetsidesoftware/actions/public/summary@v1
with:
text: |
outputs:
``````json
${{ toJSON(steps.cspell-action.outputs) }}
``````
18 changes: 4 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,6 @@ jobs:
- run: pnpm i
- run: git --no-pager diff --compact-summary --exit-code

# unit-test: # make sure unit-tests run
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: streetsidesoftware/actions/public/setup-node-pnpm@v1

# - run: pnpm i

# # Build should not be necessary to run tests
# - env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# run: GITHUB_OUTPUT="" TEST="true" pnpm test

clean-build: # make sure nothing changes with a clean build
runs-on: ubuntu-latest
steps:
Expand All @@ -48,12 +35,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: streetsidesoftware/actions/public/setup-node-pnpm@v1
- run: pnpm i

- env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: GITHUB_OUTPUT="" TEST="true" pnpm coverage
run: GITHUB_OUTPUT="" pnpm coverage

- name: Upload coverage Coveralls
uses: coverallsapp/github-action@3dfc5567390f6fa9267c0ee9c251e4c8c3f18949 # 2.2.3
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

/node_modules
/acton-src/node_modules
/action-src/dist
/debug

# install-state seems to always be changing
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ jobs:
```yaml
- uses: streetsidesoftware/cspell-action@v5
with:
# Github token used to fetch the list of changed files in the commit.
# Default: ${{ github.token }}
github_token: ''

# Define glob patterns to filter the files to be checked. Use a new line between patterns to define multiple patterns.
# The default is to check ALL files that were changed in in the pull_request or push.
# Note: `ignorePaths` defined in cspell.json still apply.
Expand Down
2 changes: 1 addition & 1 deletion action-src/fixtures/bad_params/bad_unsupported_event.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"INPUT_GITHUB_TOKEN": "$GITHUB_TOKEN",
"INPUT_INCREMENTAL_FILES_ONLY": "true",
"GITHUB_EVENT_PATH": "./fixtures/push_payload.json",
"GITHUB_EVENT_PATH": "../push_payload.json",
"GITHUB_EVENT_NAME": "fork",
"GITHUB_SHA": "a16b47a16f6c11b63cfdcf510c15ba26edd0f3d1",
"GITHUB_REF": "refs/heads/fix-resolve-path",
Expand Down
Loading

0 comments on commit 5d97173

Please sign in to comment.