Skip to content

Commit

Permalink
Merge pull request #24 from AndyTitu/andi/fix-readme-ignore
Browse files Browse the repository at this point in the history
Remove ok to test action
  • Loading branch information
AndyTitu authored Jun 11, 2024
2 parents 3697491 + 622f149 commit 3e2364d
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 56 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/integration-tests-on-forks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Validate

on:
workflow_dispatch:
inputs:
forked-pr-number:
description: "The number of the forked pull request you'd like to test"
required: true

jobs:
# Repo owner has commented /ok-to-test on a (fork-based) pull request
integration-fork:
runs-on: ubuntu-latest
permissions:
pull-requests: write
checks: write
if: github.event_name == 'workflow_dispatch'
steps:

# Check out merge commit
- name: Fork based /ok-to-test checkout
uses: actions/checkout@v4
with:
ref: 'refs/pull/${{ github.event.inputs.forked-pr-number }}/merge'

# <insert integration tests needing secrets>

- run: |
echo "Integration tests... success! ;-)"
# Update check run called "integration-fork"
- uses: actions/github-script@v6
id: update-check-run
if: ${{ always() }}
env:
number: ${{ github.event.inputs.forked-pr-number }}
job: ${{ github.job }}
# Conveniently, job.status maps to https://developer.github.com/v3/checks/runs/#update-a-check-run
conclusion: ${{ job.status }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data: pull } = await github.rest.pulls.get({
...context.repo,
pull_number: process.env.number
});
const ref = pull.head.sha;
const { data: checks } = await github.rest.checks.listForRef({
...context.repo,
ref
});
const check = checks.check_runs.filter(c => c.name === process.env.job);
const { data: result } = await github.rest.checks.update({
...context.repo,
check_run_id: check[0].id,
status: 'completed',
conclusion: process.env.conclusion
});
return result;
59 changes: 3 additions & 56 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,62 +39,9 @@ jobs:
go-version: '^1.21'
- run: go test src/variable_test.go

# Repo owner has commented /ok-to-test on a (fork-based) pull request
integration-fork:
runs-on: ubuntu-latest
permissions:
pull-requests: write
checks: write
if: |
github.event_name == 'workflow_dispatch' &&
github.event.inputs.checkout-ref != '' &&
contains(
github.event.client_payload.pull_request.head.sha,
github.event.inputs.checkout-ref
)
# this job is always skipped and its status is only updated when the integration tests are permitted to run on this code
if: github.event_name != 'pull_request' && github.event_name != 'push'
steps:

# Check out merge commit
- name: Fork based /ok-to-test checkout
uses: actions/checkout@v3
with:
ref: 'refs/pull/${{ github.event.client_payload.pull_request.number }}/merge'

# <insert integration tests needing secrets>

- run: |
echo "Integration tests... success! ;-)"
# Update check run called "integration-fork"
- uses: actions/github-script@v6
id: update-check-run
if: ${{ always() }}
env:
number: ${{ github.event.client_payload.pull_request.number }}
job: ${{ github.job }}
# Conveniently, job.status maps to https://developer.github.com/v3/checks/runs/#update-a-check-run
conclusion: ${{ job.status }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data: pull } = await github.rest.pulls.get({
...context.repo,
pull_number: process.env.number
});
const ref = pull.head.sha;
const { data: checks } = await github.rest.checks.listForRef({
...context.repo,
ref
});
const check = checks.check_runs.filter(c => c.name === process.env.job);
const { data: result } = await github.rest.checks.update({
...context.repo,
check_run_id: check[0].id,
status: 'completed',
conclusion: process.env.conclusion
});
return result;
- uses: actions/checkout@v4
62 changes: 62 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3e2364d

Please sign in to comment.