Skip to content

Git hooks test #7

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

Open
wants to merge 40 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
9e5829b
Initial commit of Husky + Linting
dylburger Feb 26, 2022
b351b1a
Adding .eslintcache to .gitignore
dylburger Feb 26, 2022
58c026e
First modification to pull request check
dylburger Feb 26, 2022
0c545a2
Another try
dylburger Feb 26, 2022
5a24575
Another try
dylburger Feb 26, 2022
0467253
Once more
dylburger Feb 26, 2022
cfc812d
Aaaand one more
dylburger Feb 26, 2022
097422b
Test
dylburger Feb 26, 2022
4566d8a
Tests
dylburger Feb 26, 2022
0bcc8e8
More tests
dylburger Feb 26, 2022
ac76c48
Testing pipefail
dylburger Feb 26, 2022
6aa39f0
More mods
dylburger Feb 26, 2022
4560c65
Let's see how long this takes
dylburger Feb 26, 2022
b26efab
New base commit logic
dylburger Feb 26, 2022
2ec532d
Let's try this one more time
dylburger Feb 26, 2022
e55463c
Test
dylburger Feb 26, 2022
6ebb3ce
More debugging
dylburger Feb 26, 2022
ab5605f
removing npm test from pre-commit hook
dylburger Feb 26, 2022
04c5278
Yet another try
dylburger Feb 26, 2022
ae0e3bb
Push
dylburger Feb 26, 2022
79f3dc7
Black magic
dylburger Feb 26, 2022
0ce997b
Will this work?
dylburger Feb 26, 2022
56355b0
More debugging
dylburger Feb 26, 2022
fced556
Playing with set
dylburger Feb 26, 2022
f7008d5
More black magic testing
dylburger Feb 26, 2022
6fe2894
Let's try this again
dylburger Feb 26, 2022
ce63c2a
Yet another test
dylburger Feb 26, 2022
7c14252
Test
dylburger Feb 26, 2022
65fbe5d
Another try
dylburger Feb 26, 2022
9ea7c26
Uno mas
dylburger Feb 26, 2022
a4aa9d0
A different approach
dylburger Feb 26, 2022
ec30321
This should pass
dylburger Feb 26, 2022
3b028a4
Improving output, adding more tests
dylburger Feb 26, 2022
13b7634
Removing set
dylburger Feb 26, 2022
69bea9f
Fixing version issues
dylburger Feb 26, 2022
e1fe315
Fixing docs link, excluding common files
dylburger Feb 27, 2022
627d09f
Correcting boolean logic
dylburger Feb 27, 2022
58b1a47
One more try
dylburger Feb 27, 2022
aec8659
Fixing version
dylburger Feb 27, 2022
8782511
Typo
dylburger Feb 27, 2022
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
74 changes: 73 additions & 1 deletion .github/workflows/pull-request-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,84 @@ on:
- master

jobs:
build:
check_version:
name: Ensure component commits modify component versions
runs-on: ubuntu-latest

steps:
- uses: actions/[email protected]
name: Checkout repo
with:
# See https://github.com/actions/checkout#checkout-v2
# This will be slow. The intent is to fetch all commits
# since the merge-base (the commit where we branched off)
# so we can check the git diff against all changed files.
# By default, the checkout action only returns the last commit,
# There's no native way to do this in the checkout action, so
# we have to fetch the entire history. See
# https://github.com/actions/checkout/issues/266#issuecomment-638346893
fetch-depth: 0
- uses: jitterbit/get-changed-files@v1
id: changed_files
name: Get changed files
# We need to get a diff of the base and HEAD commit below
- name: Return base commit
id: base_commit
uses: actions/github-script@v6
with:
script: return context.payload.pull_request?.base?.sha
result-encoding: string
- name: Return HEAD commit
id: head_commit
uses: actions/github-script@v6
with:
script: return context.payload.pull_request?.head?.sha
result-encoding: string
# Diff the changes in the HEAD ref (new branch) against the BASE ref (target branch, e.g. master)
# If the changes don't contain modifications to the version, we want to log that fact but not exit early
# Once we've checked all files, exit the script if any files failed to modify version
- id: git_diff_on_components
name: Check git diff for version changes
run: |-
commit_contained_components_that_did_not_modify_version=0
for f in ${{ steps.changed_files.outputs.all }}
do
ext="${f##*.}"
# Only run this check on modified sources or actions, excluding common files
if ([[ "$ext" == "js" ]] || [[ "$ext" == "mjs" ]]) && \
([[ "${f}" == *components/**/sources/* ]] || [[ "${f}" == *components/**/actions/* ]]) && \
[[ "${f}" != *common*.*js ]] && [[ "${f}" != **/actions/common/* ]] && [[ "${f}" != **/sources/common/* ]]
then
export BASE_COMMIT=${{steps.base_commit.outputs.result}}
export HEAD_COMMIT=${{steps.head_commit.outputs.result}}
DIFF=`git diff --unified=0 $BASE_COMMIT...$HEAD_COMMIT ${f}`
if [[ ${DIFF} != *"version:"* ]]
then
echo "You didn't modify the version of ${f}"
commit_contained_components_that_did_not_modify_version=1
fi
fi
done

if [[ $commit_contained_components_that_did_not_modify_version -eq 1 ]]
then
echo "You need to increment the version on some components. Please see the output above and https://pipedream.com/docs/components/guidelines/#versioning for more information"
exit 1
fi


spellcheck:
name: Spellcheck
runs-on: ubuntu-latest

steps:
- uses: actions/[email protected]
name: Checkout
- uses: jitterbit/get-changed-files@v1
id: changed_files
name: Get changed files
- id: md_changed_files
name: Spellcheck Markdown files
run: |-
files=''
for f in ${{ steps.changed_files.outputs.all }}
Expand All @@ -37,6 +107,8 @@ jobs:
with:
source_files: ${{ env.files }}
task_name: Markdown


lint:
name: Lint Code Base
runs-on: ubuntu-latest
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ gh-md-toc
.vscode
.idea
node_modules
.eslintcache

.vercel
.vercel
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
4 changes: 2 additions & 2 deletions components/discourse/sources/new-posts/new-posts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import discourse from "../../discourse.app.mjs";
export default {
name: "New Posts",
key: "discourse-new-posts",
version: "0.1.0",
version: "0.1.1",
type: "source",
description:
"Emits an event every time a new post is added to a topic in one of your chosen categories",
"Emit new posts added to a topic in one of your chosen categories",
...common,
props: {
...common.props,
Expand Down
4 changes: 2 additions & 2 deletions components/discourse/sources/new-topics/new-topics.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import discourse from "../../discourse.app.mjs";
export default {
name: "New Topics",
key: "discourse-new-topics",
version: "0.1.0",
version: "0.1.1",
type: "source",
description:
"Emit new events every time a new topic is posted to your chosen categories",
"Emit new topics posted to your chosen categories",
...common,
props: {
...common.props,
Expand Down
4 changes: 2 additions & 2 deletions components/discourse/sources/new-users/new-users.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import common from "../../common.mjs";
export default {
name: "New Users",
key: "discourse-new-users",
version: "0.1.0",
version: "0.1.1",
type: "source",
description:
"Emits an event every time a new user is created on your instance",
"Emit new event every time a new user is created on your instance",
...common,
hooks: {
...common.hooks,
Expand Down
2 changes: 1 addition & 1 deletion components/github/sources/common-webhook.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ module.exports = {
}

if ("zen" in body) {
console.log("Zen event to confirm subscription, nothing to emit");
console.log("Zen event to confirm subscription, nothing to emit. Exiting");
return;
}

Expand Down
4 changes: 2 additions & 2 deletions components/github/sources/new-push/new-push.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ module.exports = {
...common,
key: "github-new-push",
name: "New Push",
description: "Emit new events on each new push to a repo",
version: "0.0.6",
description: "Emit new events on each push to a repo",
version: "0.0.7",
type: "source",
dedupe: "unique",
methods: {
Expand Down
Loading