forked from silvanocerza/github-gitless-sync
-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (104 loc) · 4.2 KB
/
Copy pathintegration.yml
File metadata and controls
113 lines (104 loc) · 4.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
name: Integration tests
# Manual-only. Trigger this workflow from the GitHub UI (or
# `gh workflow run integration.yml -f suite=...`) before merging a
# change that touches sync2's network paths. The earlier nightly
# bootstrap schedule was retired — the test repos (and our GitHub
# API quota) get touched on demand rather than on a clock.
on:
workflow_dispatch:
inputs:
suite:
description: "Which suite to run"
required: true
default: "all"
type: choice
options:
- all
- bootstrap
- nonbootstrap
jobs:
integration:
runs-on: ubuntu-latest
# Only one integration job at a time — the test repos are shared
# state and parallel runs would trample each other.
concurrency:
group: integration-tests
cancel-in-progress: false
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: latest-10
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
# Build first — fail fast on TS regressions before burning API quota.
- name: Build plugin
run: pnpm build
- name: Run integration tests
env:
# Fine-grained PAT scoped to the private test repo. Used by
# every test except bootstrap. Cannot create/delete repos.
GITHUB_TOKEN: ${{ secrets.INTEGRATION_TEST_TOKEN }}
# Classic PAT with public_repo + delete_repo. Used ONLY by
# bootstrap tests against the ephemeral public test repo.
GITHUB_BOOTSTRAP_TOKEN: ${{ secrets.INTEGRATION_BOOTSTRAP_TEST_TOKEN }}
# Repo identifiers — non-secret, exposed via GitHub vars.
INT_TEST_OWNER: ${{ vars.INT_TEST_OWNER }}
INT_TEST_REPO: ${{ vars.INT_TEST_REPO }}
INT_BOOTSTRAP_TEST_REPO: ${{ vars.INT_BOOTSTRAP_TEST_REPO }}
INT_TEST_BRANCH_PREFIX: ${{ vars.INT_TEST_BRANCH_PREFIX || 'int-test' }}
run: |
case "${{ inputs.suite }}" in
bootstrap) pnpm test:integration:bootstrap ;;
nonbootstrap) pnpm test:integration:nonbootstrap ;;
all|*) pnpm test:integration ;;
esac
# Best-effort cleanup of stray feature branches in the PRIVATE
# test repo. Bootstrap repo doesn't need this — its lifecycle
# is delete+recreate per test.
- name: Cleanup leftover branches
if: always()
env:
GITHUB_TOKEN: ${{ secrets.INTEGRATION_TEST_TOKEN }}
INT_TEST_OWNER: ${{ vars.INT_TEST_OWNER }}
INT_TEST_REPO: ${{ vars.INT_TEST_REPO }}
INT_TEST_BRANCH_PREFIX: ${{ vars.INT_TEST_BRANCH_PREFIX || 'int-test' }}
run: |
node -e "
(async () => {
const owner = process.env.INT_TEST_OWNER;
const repo = process.env.INT_TEST_REPO;
const token = process.env.GITHUB_TOKEN;
const prefix = process.env.INT_TEST_BRANCH_PREFIX;
const headers = {
Authorization: 'Bearer ' + token,
Accept: 'application/vnd.github+json',
'X-GitHub-Api-Version': '2022-11-28',
};
const list = await fetch(
'https://api.github.com/repos/' + owner + '/' + repo + '/branches?per_page=100',
{ headers }
);
if (list.status === 404 || list.status === 409) return;
if (list.status !== 200) {
console.warn('list branches', list.status);
return;
}
const branches = await list.json();
const stray = branches.filter(b => b.name.startsWith(prefix + '-'));
for (const b of stray) {
const del = await fetch(
'https://api.github.com/repos/' + owner + '/' + repo + '/git/refs/heads/' + encodeURIComponent(b.name),
{ method: 'DELETE', headers }
);
console.log('cleanup', b.name, '->', del.status);
}
})().catch(e => { console.error(e); process.exitCode = 0; });
"