Andi/fix readme ignore #22
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
# This workflow builds, tests, and checks linting for the 1Password Python SDK. | |
name: Validate | |
on: | |
pull_request: | |
workflow_dispatch: | |
checkout-ref: | |
required: true | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '^1.21' | |
- name: Build | |
run: go build -v ./... | |
# Branch-based pull request | |
integration-trusted: | |
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository | |
runs-on: ubuntu-latest | |
env: | |
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
steps: | |
- name: Branch based PR checkout | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
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 == 'repository_dispatch' && | |
github.event.inputs.checkout-ref != '' && | |
contains( | |
github.event.client_payload.pull_request.head.sha, | |
github.event.inputs.checkout-ref | |
) | |
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; |