-
Notifications
You must be signed in to change notification settings - Fork 556
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* starts working on action * updates changelog Co-authored-by: Rishabh <[email protected]>
- Loading branch information
1 parent
c6df7f0
commit 9f545ef
Showing
5 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
package-lock.json |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "helpers", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "test-pass-check-pr.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"axios": "^0.26.1" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const { default: axios } = require("axios"); | ||
|
||
let thisRunId = process.env.RUN_ID; | ||
thisRunId = thisRunId.trim(); | ||
|
||
axios.get(`https://api.github.com/repos/${process.env.REPO}/actions/runs?branch=${process.env.BRANCH}`).then(async result => { | ||
let data = result.data; | ||
let passed = false; | ||
let currentSHA = undefined; | ||
|
||
data.workflow_runs.forEach(run => { | ||
if ((run.id + "") === thisRunId) { | ||
currentSHA = run.head_sha; | ||
} | ||
}); | ||
|
||
if (currentSHA !== undefined) { | ||
for (let i = 0; i < data.workflow_runs.length; i++) { | ||
let run = data.workflow_runs[i]; | ||
if (run.head_sha === currentSHA) { | ||
// here we have all the jobs that have run on this commit. | ||
let workflow_id = run.workflow_id; | ||
let workflow = await axios.get(`https://api.github.com/repos/${process.env.REPO}/actions/workflows/${workflow_id}`); | ||
let workflowData = workflow.data; | ||
if (workflowData.path === ".github/workflows/tests.yml") { | ||
if (run.conclusion === "success") { | ||
passed = true; | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
if (!passed) { | ||
console.log("You need to trigger the \"Run tests\" github action and make that succeed.\n\nSee https://github.com/supertokens/supertokens-core/blob/master/CONTRIBUTING.md#using-github-actions\n\nOnce successful, re-run this action.") | ||
} | ||
|
||
process.exit(passed ? 0 : 1); | ||
}) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: "Check if \"Run tests\" action succeeded" | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- reopened | ||
- edited | ||
- synchronize | ||
|
||
jobs: | ||
pr-run-test-action: | ||
name: Check if "Run tests" action succeeded | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: node install | ||
run: cd ./.github/helpers && npm i | ||
- name: Calling github API | ||
run: cd ./.github/helpers && REPO=${{ github.repository }} RUN_ID=${{ github.run_id }} BRANCH=${{ github.head_ref }} JOB_ID=${{ github.job }} node test-pass-check-pr.js |
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