Compare commits
11 Commits
v3.0.0-bet
...
v3.0.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a0d050558c | ||
|
|
6d13b5ae0d | ||
|
|
fee1f7d63c | ||
|
|
6bda5bc141 | ||
|
|
b04413352d | ||
|
|
5cbc65624c | ||
|
|
b4f638f48e | ||
|
|
28bdc1ab05 | ||
|
|
d53a1cdfde | ||
|
|
f863ba5554 | ||
|
|
c2937b00bd |
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@@ -56,7 +56,7 @@ jobs:
|
|||||||
- run: echo '${{ steps.get-repository.outputs.data }}'
|
- run: echo '${{ steps.get-repository.outputs.data }}'
|
||||||
|
|
||||||
end-to-end-proxy:
|
end-to-end-proxy:
|
||||||
name: End-to-End with unreachable proxy
|
name: end-to-end with unreachable proxy
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
# do not run from forks, as forks don’t have access to repository secrets
|
# do not run from forks, as forks don’t have access to repository secrets
|
||||||
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.owner.login == github.event.pull_request.base.repo.owner.login
|
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.owner.login == github.event.pull_request.base.repo.owner.login
|
||||||
|
|||||||
22772
dist/main.cjs
vendored
22772
dist/main.cjs
vendored
File diff suppressed because one or more lines are too long
22663
dist/post.cjs
vendored
22663
dist/post.cjs
vendored
File diff suppressed because one or more lines are too long
@@ -1,4 +1,4 @@
|
|||||||
import core from "@actions/core";
|
import * as core from "@actions/core";
|
||||||
import { request } from "@octokit/request";
|
import { request } from "@octokit/request";
|
||||||
|
|
||||||
// Get the GitHub API URL from the action input and remove any trailing slash
|
// Get the GitHub API URL from the action input and remove any trailing slash
|
||||||
|
|||||||
2
main.js
2
main.js
@@ -1,6 +1,6 @@
|
|||||||
// @ts-check
|
// @ts-check
|
||||||
|
|
||||||
import core from "@actions/core";
|
import * as core from "@actions/core";
|
||||||
import { createAppAuth } from "@octokit/auth-app";
|
import { createAppAuth } from "@octokit/auth-app";
|
||||||
|
|
||||||
import { getPermissionsFromInputs } from "./lib/get-permissions-from-inputs.js";
|
import { getPermissionsFromInputs } from "./lib/get-permissions-from-inputs.js";
|
||||||
|
|||||||
1999
package-lock.json
generated
1999
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
17
package.json
17
package.json
@@ -2,7 +2,7 @@
|
|||||||
"name": "create-github-app-token",
|
"name": "create-github-app-token",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "3.0.0-beta.4",
|
"version": "3.0.0-beta.6",
|
||||||
"description": "GitHub Action for creating a GitHub App Installation Access Token",
|
"description": "GitHub Action for creating a GitHub App Installation Access Token",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=24.4.0"
|
"node": ">=24.4.0"
|
||||||
@@ -10,26 +10,23 @@
|
|||||||
"packageManager": "npm@10.9.4",
|
"packageManager": "npm@10.9.4",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "esbuild main.js post.js --bundle --outdir=dist --out-extension:.js=.cjs --platform=node --packages=bundle",
|
"build": "esbuild main.js post.js --bundle --outdir=dist --out-extension:.js=.cjs --platform=node --packages=bundle",
|
||||||
"test": "c8 --100 ava tests/index.js",
|
"test": "c8 --100 node --test tests/index.js",
|
||||||
"coverage": "c8 report --reporter html",
|
"coverage": "c8 report --reporter html",
|
||||||
"postcoverage": "open-cli coverage/index.html"
|
"postcoverage": "open-cli coverage/index.html"
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.11.1",
|
"@actions/core": "^3.0.0",
|
||||||
"@octokit/auth-app": "^8.1.2",
|
"@octokit/auth-app": "^8.2.0",
|
||||||
"@octokit/request": "^10.0.3",
|
"@octokit/request": "^10.0.8",
|
||||||
"p-retry": "^7.1.0",
|
"p-retry": "^7.1.1",
|
||||||
"undici": "^7.16.0"
|
"undici": "^7.24.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@octokit/openapi": "^21.0.0",
|
"@octokit/openapi": "^21.0.0",
|
||||||
"@sinonjs/fake-timers": "^15.1.0",
|
|
||||||
"ava": "^6.4.1",
|
|
||||||
"c8": "^10.1.3",
|
"c8": "^10.1.3",
|
||||||
"dotenv": "^17.3.1",
|
"dotenv": "^17.3.1",
|
||||||
"esbuild": "^0.27.3",
|
"esbuild": "^0.27.3",
|
||||||
"execa": "^9.6.1",
|
|
||||||
"open-cli": "^8.0.0",
|
"open-cli": "^8.0.0",
|
||||||
"yaml": "^2.8.2"
|
"yaml": "^2.8.2"
|
||||||
},
|
},
|
||||||
|
|||||||
2
post.js
2
post.js
@@ -1,6 +1,6 @@
|
|||||||
// @ts-check
|
// @ts-check
|
||||||
|
|
||||||
import core from "@actions/core";
|
import * as core from "@actions/core";
|
||||||
|
|
||||||
import { post } from "./lib/post.js";
|
import { post } from "./lib/post.js";
|
||||||
import request, { ensureNativeProxySupport } from "./lib/request.js";
|
import request, { ensureNativeProxySupport } from "./lib/request.js";
|
||||||
|
|||||||
@@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
Add one test file per scenario. You can run them in isolation with:
|
Add one test file per scenario. You can run them in isolation with:
|
||||||
|
|
||||||
```bash
|
```
|
||||||
node tests/post-token-set.test.js
|
node tests/post-token-set.test.js
|
||||||
```
|
```
|
||||||
|
|
||||||
All tests are run together in [tests/index.js](index.js), which can be executed with ava
|
All tests are run together in [tests/index.js](index.js), which can be executed with Node's built-in test runner
|
||||||
|
|
||||||
```
|
```
|
||||||
npx ava tests/index.js
|
node --test tests/index.js
|
||||||
```
|
```
|
||||||
|
|
||||||
or with npm
|
or with npm
|
||||||
@@ -20,7 +20,13 @@ npm test
|
|||||||
|
|
||||||
## How the tests work
|
## How the tests work
|
||||||
|
|
||||||
The output from the tests is captured into a snapshot ([tests/snapshots/index.js.md](snapshots/index.js.md)). It includes all requests sent by our scripts to verify it's working correctly and to prevent regressions.
|
The output from the tests is captured into a snapshot ([tests/index.js.snapshot](index.js.snapshot)). It includes all requests sent by our scripts to verify it's working correctly and to prevent regressions.
|
||||||
|
|
||||||
|
To update snapshots after an intentional change:
|
||||||
|
|
||||||
|
```
|
||||||
|
node --test --test-update-snapshots tests/index.js
|
||||||
|
```
|
||||||
|
|
||||||
## How to add a new test
|
## How to add a new test
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,23 @@
|
|||||||
import { readdirSync } from "node:fs";
|
import { readdirSync } from "node:fs";
|
||||||
|
import { execFile } from "node:child_process";
|
||||||
|
import { promisify } from "node:util";
|
||||||
|
|
||||||
import test from "ava";
|
import { snapshot, test } from "node:test";
|
||||||
import { execa } from "execa";
|
|
||||||
|
const execFileAsync = promisify(execFile);
|
||||||
|
|
||||||
|
// Serialize strings as-is so multiline output is human-readable in snapshots
|
||||||
|
snapshot.setDefaultSnapshotSerializers([
|
||||||
|
(value) => (typeof value === "string" ? value : undefined),
|
||||||
|
]);
|
||||||
|
|
||||||
// Get all files in tests directory
|
// Get all files in tests directory
|
||||||
const files = readdirSync("tests");
|
const files = readdirSync("tests");
|
||||||
|
|
||||||
// Files to ignore
|
// Files to ignore
|
||||||
const ignore = ["index.js", "main.js", "README.md", "snapshots"];
|
const ignore = ["index.js", "index.js.snapshot", "main.js", "README.md"];
|
||||||
|
|
||||||
const testFiles = files.filter((file) => !ignore.includes(file));
|
const testFiles = files.filter((file) => !ignore.includes(file)).sort();
|
||||||
|
|
||||||
// Throw an error if there is a file that does not end with test.js in the tests directory
|
// Throw an error if there is a file that does not end with test.js in the tests directory
|
||||||
for (const file of testFiles) {
|
for (const file of testFiles) {
|
||||||
@@ -18,20 +26,31 @@ for (const file of testFiles) {
|
|||||||
}
|
}
|
||||||
test(file, async (t) => {
|
test(file, async (t) => {
|
||||||
// Override Actions environment variables that change `core`’s behavior
|
// Override Actions environment variables that change `core`’s behavior
|
||||||
const env = {
|
const {
|
||||||
GITHUB_OUTPUT: undefined,
|
GITHUB_OUTPUT,
|
||||||
GITHUB_STATE: undefined,
|
GITHUB_STATE,
|
||||||
HTTP_PROXY: undefined,
|
HTTP_PROXY,
|
||||||
HTTPS_PROXY: undefined,
|
HTTPS_PROXY,
|
||||||
http_proxy: undefined,
|
http_proxy,
|
||||||
https_proxy: undefined,
|
https_proxy,
|
||||||
NO_PROXY: undefined,
|
NO_PROXY,
|
||||||
no_proxy: undefined,
|
no_proxy,
|
||||||
NODE_OPTIONS: undefined,
|
NODE_OPTIONS,
|
||||||
NODE_USE_ENV_PROXY: undefined,
|
NODE_USE_ENV_PROXY,
|
||||||
};
|
...env
|
||||||
const { stderr, stdout } = await execa("node", [`tests/${file}`], { env });
|
} = process.env;
|
||||||
t.snapshot(stderr, "stderr");
|
const { stderr, stdout } = await execFileAsync("node", [`tests/${file}`], {
|
||||||
t.snapshot(stdout, "stdout");
|
env,
|
||||||
|
});
|
||||||
|
const trimmedStderr = stderr.replace(/\r?\n$/, "");
|
||||||
|
const trimmedStdout = stdout.replace(/\r?\n$/, "");
|
||||||
|
await t.test("stderr", (t) => {
|
||||||
|
if (trimmedStderr) t.assert.snapshot(trimmedStderr);
|
||||||
|
else t.assert.strictEqual(trimmedStderr, "");
|
||||||
|
});
|
||||||
|
await t.test("stdout", (t) => {
|
||||||
|
if (trimmedStdout) t.assert.snapshot(trimmedStdout);
|
||||||
|
else t.assert.strictEqual(trimmedStdout, "");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
274
tests/index.js.snapshot
Normal file
274
tests/index.js.snapshot
Normal file
@@ -0,0 +1,274 @@
|
|||||||
|
exports[`main-custom-github-api-url.test.js > stdout 1`] = `
|
||||||
|
Inputs 'owner' and 'repositories' are set. Creating token for the following repositories:
|
||||||
|
|
||||||
|
- actions/create-github-app-token
|
||||||
|
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
||||||
|
|
||||||
|
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
||||||
|
|
||||||
|
::set-output name=installation-id::123456
|
||||||
|
|
||||||
|
::set-output name=app-slug::github-actions
|
||||||
|
::save-state name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
||||||
|
::save-state name=expiresAt::2016-07-11T22:14:10Z
|
||||||
|
--- REQUESTS ---
|
||||||
|
GET /api/v3/repos/actions/create-github-app-token/installation
|
||||||
|
POST /api/v3/app/installations/123456/access_tokens
|
||||||
|
{"repositories":["create-github-app-token"]}
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`main-missing-owner.test.js > stderr 1`] = `
|
||||||
|
GITHUB_REPOSITORY_OWNER missing, must be set to '<owner>'
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`main-missing-repository.test.js > stderr 1`] = `
|
||||||
|
GITHUB_REPOSITORY missing, must be set to '<owner>/<repo>'
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`main-private-key-with-escaped-newlines.test.js > stdout 1`] = `
|
||||||
|
Inputs 'owner' and 'repositories' are not set. Creating token for this repository (actions/create-github-app-token).
|
||||||
|
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
||||||
|
|
||||||
|
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
||||||
|
|
||||||
|
::set-output name=installation-id::123456
|
||||||
|
|
||||||
|
::set-output name=app-slug::github-actions
|
||||||
|
::save-state name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
||||||
|
::save-state name=expiresAt::2016-07-11T22:14:10Z
|
||||||
|
--- REQUESTS ---
|
||||||
|
GET /repos/actions/create-github-app-token/installation
|
||||||
|
POST /app/installations/123456/access_tokens
|
||||||
|
{"repositories":["create-github-app-token"]}
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`main-proxy-requires-native-support.test.js > stderr 1`] = `
|
||||||
|
A proxy environment variable is set, but Node.js native proxy support is not enabled. Set NODE_USE_ENV_PROXY=1 for this action step.
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`main-proxy-requires-native-support.test.js > stdout 1`] = `
|
||||||
|
::error::A proxy environment variable is set, but Node.js native proxy support is not enabled. Set NODE_USE_ENV_PROXY=1 for this action step.
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`main-repo-skew.test.js > stderr 1`] = `
|
||||||
|
'Issued at' claim ('iat') must be an Integer representing the time that the assertion was issued.
|
||||||
|
[@octokit/auth-app] GitHub API time and system time are different by 30 seconds. Retrying request with the difference accounted for.
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`main-repo-skew.test.js > stdout 1`] = `
|
||||||
|
Inputs 'owner' and 'repositories' are set. Creating token for the following repositories:
|
||||||
|
|
||||||
|
- actions/failed-repo
|
||||||
|
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
||||||
|
|
||||||
|
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
||||||
|
|
||||||
|
::set-output name=installation-id::123456
|
||||||
|
|
||||||
|
::set-output name=app-slug::github-actions
|
||||||
|
::save-state name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
||||||
|
::save-state name=expiresAt::2016-07-11T22:14:10Z
|
||||||
|
--- REQUESTS ---
|
||||||
|
GET /repos/actions/failed-repo/installation
|
||||||
|
GET /repos/actions/failed-repo/installation
|
||||||
|
POST /app/installations/123456/access_tokens
|
||||||
|
{"repositories":["failed-repo"]}
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`main-token-get-owner-set-fail-response.test.js > stdout 1`] = `
|
||||||
|
Input 'repositories' is not set. Creating token for all repositories owned by smockle.
|
||||||
|
Failed to create token for "smockle" (attempt 1): GitHub API not available
|
||||||
|
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
||||||
|
|
||||||
|
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
||||||
|
|
||||||
|
::set-output name=installation-id::123456
|
||||||
|
|
||||||
|
::set-output name=app-slug::github-actions
|
||||||
|
::save-state name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
||||||
|
::save-state name=expiresAt::2016-07-11T22:14:10Z
|
||||||
|
--- REQUESTS ---
|
||||||
|
GET /users/smockle/installation
|
||||||
|
GET /users/smockle/installation
|
||||||
|
POST /app/installations/123456/access_tokens
|
||||||
|
null
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`main-token-get-owner-set-repo-fail-response.test.js > stdout 1`] = `
|
||||||
|
Inputs 'owner' and 'repositories' are set. Creating token for the following repositories:
|
||||||
|
|
||||||
|
- actions/failed-repo
|
||||||
|
Failed to create token for "failed-repo" (attempt 1): GitHub API not available
|
||||||
|
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
||||||
|
|
||||||
|
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
||||||
|
|
||||||
|
::set-output name=installation-id::123456
|
||||||
|
|
||||||
|
::set-output name=app-slug::github-actions
|
||||||
|
::save-state name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
||||||
|
::save-state name=expiresAt::2016-07-11T22:14:10Z
|
||||||
|
--- REQUESTS ---
|
||||||
|
GET /repos/actions/failed-repo/installation
|
||||||
|
GET /repos/actions/failed-repo/installation
|
||||||
|
POST /app/installations/123456/access_tokens
|
||||||
|
{"repositories":["failed-repo"]}
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`main-token-get-owner-set-repo-set-to-many-newline.test.js > stdout 1`] = `
|
||||||
|
Inputs 'owner' and 'repositories' are set. Creating token for the following repositories:
|
||||||
|
|
||||||
|
- actions/create-github-app-token
|
||||||
|
- actions/toolkit
|
||||||
|
- actions/checkout
|
||||||
|
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
||||||
|
|
||||||
|
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
||||||
|
|
||||||
|
::set-output name=installation-id::123456
|
||||||
|
|
||||||
|
::set-output name=app-slug::github-actions
|
||||||
|
::save-state name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
||||||
|
::save-state name=expiresAt::2016-07-11T22:14:10Z
|
||||||
|
--- REQUESTS ---
|
||||||
|
GET /repos/actions/create-github-app-token/installation
|
||||||
|
POST /app/installations/123456/access_tokens
|
||||||
|
{"repositories":["create-github-app-token","toolkit","checkout"]}
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`main-token-get-owner-set-repo-set-to-many.test.js > stdout 1`] = `
|
||||||
|
Inputs 'owner' and 'repositories' are set. Creating token for the following repositories:
|
||||||
|
|
||||||
|
- actions/create-github-app-token
|
||||||
|
- actions/toolkit
|
||||||
|
- actions/checkout
|
||||||
|
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
||||||
|
|
||||||
|
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
||||||
|
|
||||||
|
::set-output name=installation-id::123456
|
||||||
|
|
||||||
|
::set-output name=app-slug::github-actions
|
||||||
|
::save-state name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
||||||
|
::save-state name=expiresAt::2016-07-11T22:14:10Z
|
||||||
|
--- REQUESTS ---
|
||||||
|
GET /repos/actions/create-github-app-token/installation
|
||||||
|
POST /app/installations/123456/access_tokens
|
||||||
|
{"repositories":["create-github-app-token","toolkit","checkout"]}
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`main-token-get-owner-set-repo-set-to-one.test.js > stdout 1`] = `
|
||||||
|
Inputs 'owner' and 'repositories' are set. Creating token for the following repositories:
|
||||||
|
|
||||||
|
- actions/create-github-app-token
|
||||||
|
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
||||||
|
|
||||||
|
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
||||||
|
|
||||||
|
::set-output name=installation-id::123456
|
||||||
|
|
||||||
|
::set-output name=app-slug::github-actions
|
||||||
|
::save-state name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
||||||
|
::save-state name=expiresAt::2016-07-11T22:14:10Z
|
||||||
|
--- REQUESTS ---
|
||||||
|
GET /repos/actions/create-github-app-token/installation
|
||||||
|
POST /app/installations/123456/access_tokens
|
||||||
|
{"repositories":["create-github-app-token"]}
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`main-token-get-owner-set-repo-unset.test.js > stdout 1`] = `
|
||||||
|
Input 'repositories' is not set. Creating token for all repositories owned by actions.
|
||||||
|
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
||||||
|
|
||||||
|
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
||||||
|
|
||||||
|
::set-output name=installation-id::123456
|
||||||
|
|
||||||
|
::set-output name=app-slug::github-actions
|
||||||
|
::save-state name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
||||||
|
::save-state name=expiresAt::2016-07-11T22:14:10Z
|
||||||
|
--- REQUESTS ---
|
||||||
|
GET /users/actions/installation
|
||||||
|
POST /app/installations/123456/access_tokens
|
||||||
|
null
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`main-token-get-owner-unset-repo-set.test.js > stdout 1`] = `
|
||||||
|
No 'owner' input provided. Using default owner 'actions' to create token for the following repositories:
|
||||||
|
- actions/create-github-app-token
|
||||||
|
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
||||||
|
|
||||||
|
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
||||||
|
|
||||||
|
::set-output name=installation-id::123456
|
||||||
|
|
||||||
|
::set-output name=app-slug::github-actions
|
||||||
|
::save-state name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
||||||
|
::save-state name=expiresAt::2016-07-11T22:14:10Z
|
||||||
|
--- REQUESTS ---
|
||||||
|
GET /repos/actions/create-github-app-token/installation
|
||||||
|
POST /app/installations/123456/access_tokens
|
||||||
|
{"repositories":["create-github-app-token"]}
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`main-token-get-owner-unset-repo-unset.test.js > stdout 1`] = `
|
||||||
|
Inputs 'owner' and 'repositories' are not set. Creating token for this repository (actions/create-github-app-token).
|
||||||
|
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
||||||
|
|
||||||
|
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
||||||
|
|
||||||
|
::set-output name=installation-id::123456
|
||||||
|
|
||||||
|
::set-output name=app-slug::github-actions
|
||||||
|
::save-state name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
||||||
|
::save-state name=expiresAt::2016-07-11T22:14:10Z
|
||||||
|
--- REQUESTS ---
|
||||||
|
GET /repos/actions/create-github-app-token/installation
|
||||||
|
POST /app/installations/123456/access_tokens
|
||||||
|
{"repositories":["create-github-app-token"]}
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`main-token-permissions-set.test.js > stdout 1`] = `
|
||||||
|
Inputs 'owner' and 'repositories' are not set. Creating token for this repository (actions/create-github-app-token).
|
||||||
|
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
||||||
|
|
||||||
|
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
||||||
|
|
||||||
|
::set-output name=installation-id::123456
|
||||||
|
|
||||||
|
::set-output name=app-slug::github-actions
|
||||||
|
::save-state name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a
|
||||||
|
::save-state name=expiresAt::2016-07-11T22:14:10Z
|
||||||
|
--- REQUESTS ---
|
||||||
|
GET /repos/actions/create-github-app-token/installation
|
||||||
|
POST /app/installations/123456/access_tokens
|
||||||
|
{"repositories":["create-github-app-token"],"permissions":{"issues":"write","pull_requests":"read"}}
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`post-proxy-requires-native-support.test.js > stderr 1`] = `
|
||||||
|
A proxy environment variable is set, but Node.js native proxy support is not enabled. Set NODE_USE_ENV_PROXY=1 for this action step.
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`post-proxy-requires-native-support.test.js > stdout 1`] = `
|
||||||
|
::error::A proxy environment variable is set, but Node.js native proxy support is not enabled. Set NODE_USE_ENV_PROXY=1 for this action step.
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`post-revoke-token-fail-response.test.js > stdout 1`] = `
|
||||||
|
::warning::Token revocation failed:
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`post-token-expired.test.js > stdout 1`] = `
|
||||||
|
Token expired, skipping token revocation
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`post-token-set.test.js > stdout 1`] = `
|
||||||
|
Token revoked
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`post-token-skipped.test.js > stdout 1`] = `
|
||||||
|
Token revocation was skipped
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`post-token-unset.test.js > stdout 1`] = `
|
||||||
|
Token is not set
|
||||||
|
`;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { test } from "./main.js";
|
import { mock } from "node:test";
|
||||||
|
|
||||||
import { install } from "@sinonjs/fake-timers";
|
import { test } from "./main.js";
|
||||||
|
|
||||||
// Verify `main` retry when the clock has drifted.
|
// Verify `main` retry when the clock has drifted.
|
||||||
await test((mockPool) => {
|
await test((mockPool) => {
|
||||||
@@ -11,7 +11,7 @@ await test((mockPool) => {
|
|||||||
const mockInstallationId = "123456";
|
const mockInstallationId = "123456";
|
||||||
const mockAppSlug = "github-actions";
|
const mockAppSlug = "github-actions";
|
||||||
|
|
||||||
install({ now: 0, toFake: ["Date"] });
|
mock.timers.enable({ apis: ["Date"], now: 0 });
|
||||||
|
|
||||||
mockPool
|
mockPool
|
||||||
.intercept({
|
.intercept({
|
||||||
@@ -59,4 +59,6 @@ await test((mockPool) => {
|
|||||||
};
|
};
|
||||||
})
|
})
|
||||||
.times(2);
|
.times(2);
|
||||||
|
}).finally(() => {
|
||||||
|
mock.timers.reset();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,404 +0,0 @@
|
|||||||
# Snapshot report for `tests/index.js`
|
|
||||||
|
|
||||||
The actual snapshot is saved in `index.js.snap`.
|
|
||||||
|
|
||||||
Generated by [AVA](https://avajs.dev).
|
|
||||||
|
|
||||||
## action-deprecated-inputs.test.js
|
|
||||||
|
|
||||||
> stderr
|
|
||||||
|
|
||||||
''
|
|
||||||
|
|
||||||
> stdout
|
|
||||||
|
|
||||||
''
|
|
||||||
|
|
||||||
## main-custom-github-api-url.test.js
|
|
||||||
|
|
||||||
> stderr
|
|
||||||
|
|
||||||
''
|
|
||||||
|
|
||||||
> stdout
|
|
||||||
|
|
||||||
`Inputs 'owner' and 'repositories' are set. Creating token for the following repositories:␊
|
|
||||||
␊
|
|
||||||
- actions/create-github-app-token␊
|
|
||||||
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
|
||||||
␊
|
|
||||||
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
|
||||||
␊
|
|
||||||
::set-output name=installation-id::123456␊
|
|
||||||
␊
|
|
||||||
::set-output name=app-slug::github-actions␊
|
|
||||||
::save-state name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
|
||||||
::save-state name=expiresAt::2016-07-11T22:14:10Z␊
|
|
||||||
--- REQUESTS ---␊
|
|
||||||
GET /api/v3/repos/actions/create-github-app-token/installation␊
|
|
||||||
POST /api/v3/app/installations/123456/access_tokens␊
|
|
||||||
{"repositories":["create-github-app-token"]}`
|
|
||||||
|
|
||||||
## main-missing-owner.test.js
|
|
||||||
|
|
||||||
> stderr
|
|
||||||
|
|
||||||
'GITHUB_REPOSITORY_OWNER missing, must be set to \'<owner>\''
|
|
||||||
|
|
||||||
> stdout
|
|
||||||
|
|
||||||
''
|
|
||||||
|
|
||||||
## main-missing-repository.test.js
|
|
||||||
|
|
||||||
> stderr
|
|
||||||
|
|
||||||
'GITHUB_REPOSITORY missing, must be set to \'<owner>/<repo>\''
|
|
||||||
|
|
||||||
> stdout
|
|
||||||
|
|
||||||
''
|
|
||||||
|
|
||||||
## main-private-key-with-escaped-newlines.test.js
|
|
||||||
|
|
||||||
> stderr
|
|
||||||
|
|
||||||
''
|
|
||||||
|
|
||||||
> stdout
|
|
||||||
|
|
||||||
`Inputs 'owner' and 'repositories' are not set. Creating token for this repository (actions/create-github-app-token).␊
|
|
||||||
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
|
||||||
␊
|
|
||||||
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
|
||||||
␊
|
|
||||||
::set-output name=installation-id::123456␊
|
|
||||||
␊
|
|
||||||
::set-output name=app-slug::github-actions␊
|
|
||||||
::save-state name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
|
||||||
::save-state name=expiresAt::2016-07-11T22:14:10Z␊
|
|
||||||
--- REQUESTS ---␊
|
|
||||||
GET /repos/actions/create-github-app-token/installation␊
|
|
||||||
POST /app/installations/123456/access_tokens␊
|
|
||||||
{"repositories":["create-github-app-token"]}`
|
|
||||||
|
|
||||||
## main-proxy-requires-native-support.test.js
|
|
||||||
|
|
||||||
> stderr
|
|
||||||
|
|
||||||
'A proxy environment variable is set, but Node.js native proxy support is not enabled. Set NODE_USE_ENV_PROXY=1 for this action step.'
|
|
||||||
|
|
||||||
> stdout
|
|
||||||
|
|
||||||
'::error::A proxy environment variable is set, but Node.js native proxy support is not enabled. Set NODE_USE_ENV_PROXY=1 for this action step.'
|
|
||||||
|
|
||||||
## main-repo-skew.test.js
|
|
||||||
|
|
||||||
> stderr
|
|
||||||
|
|
||||||
`'Issued at' claim ('iat') must be an Integer representing the time that the assertion was issued.␊
|
|
||||||
[@octokit/auth-app] GitHub API time and system time are different by 30 seconds. Retrying request with the difference accounted for.`
|
|
||||||
|
|
||||||
> stdout
|
|
||||||
|
|
||||||
`Inputs 'owner' and 'repositories' are set. Creating token for the following repositories:␊
|
|
||||||
␊
|
|
||||||
- actions/failed-repo␊
|
|
||||||
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
|
||||||
␊
|
|
||||||
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
|
||||||
␊
|
|
||||||
::set-output name=installation-id::123456␊
|
|
||||||
␊
|
|
||||||
::set-output name=app-slug::github-actions␊
|
|
||||||
::save-state name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
|
||||||
::save-state name=expiresAt::2016-07-11T22:14:10Z␊
|
|
||||||
--- REQUESTS ---␊
|
|
||||||
GET /repos/actions/failed-repo/installation␊
|
|
||||||
GET /repos/actions/failed-repo/installation␊
|
|
||||||
POST /app/installations/123456/access_tokens␊
|
|
||||||
{"repositories":["failed-repo"]}`
|
|
||||||
|
|
||||||
## main-token-get-owner-set-fail-response.test.js
|
|
||||||
|
|
||||||
> stderr
|
|
||||||
|
|
||||||
''
|
|
||||||
|
|
||||||
> stdout
|
|
||||||
|
|
||||||
`Input 'repositories' is not set. Creating token for all repositories owned by smockle.␊
|
|
||||||
Failed to create token for "smockle" (attempt 1): GitHub API not available␊
|
|
||||||
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
|
||||||
␊
|
|
||||||
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
|
||||||
␊
|
|
||||||
::set-output name=installation-id::123456␊
|
|
||||||
␊
|
|
||||||
::set-output name=app-slug::github-actions␊
|
|
||||||
::save-state name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
|
||||||
::save-state name=expiresAt::2016-07-11T22:14:10Z␊
|
|
||||||
--- REQUESTS ---␊
|
|
||||||
GET /users/smockle/installation␊
|
|
||||||
GET /users/smockle/installation␊
|
|
||||||
POST /app/installations/123456/access_tokens␊
|
|
||||||
null`
|
|
||||||
|
|
||||||
## main-token-get-owner-set-repo-fail-response.test.js
|
|
||||||
|
|
||||||
> stderr
|
|
||||||
|
|
||||||
''
|
|
||||||
|
|
||||||
> stdout
|
|
||||||
|
|
||||||
`Inputs 'owner' and 'repositories' are set. Creating token for the following repositories:␊
|
|
||||||
␊
|
|
||||||
- actions/failed-repo␊
|
|
||||||
Failed to create token for "failed-repo" (attempt 1): GitHub API not available␊
|
|
||||||
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
|
||||||
␊
|
|
||||||
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
|
||||||
␊
|
|
||||||
::set-output name=installation-id::123456␊
|
|
||||||
␊
|
|
||||||
::set-output name=app-slug::github-actions␊
|
|
||||||
::save-state name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
|
||||||
::save-state name=expiresAt::2016-07-11T22:14:10Z␊
|
|
||||||
--- REQUESTS ---␊
|
|
||||||
GET /repos/actions/failed-repo/installation␊
|
|
||||||
GET /repos/actions/failed-repo/installation␊
|
|
||||||
POST /app/installations/123456/access_tokens␊
|
|
||||||
{"repositories":["failed-repo"]}`
|
|
||||||
|
|
||||||
## main-token-get-owner-set-repo-set-to-many-newline.test.js
|
|
||||||
|
|
||||||
> stderr
|
|
||||||
|
|
||||||
''
|
|
||||||
|
|
||||||
> stdout
|
|
||||||
|
|
||||||
`Inputs 'owner' and 'repositories' are set. Creating token for the following repositories:␊
|
|
||||||
␊
|
|
||||||
- actions/create-github-app-token␊
|
|
||||||
- actions/toolkit␊
|
|
||||||
- actions/checkout␊
|
|
||||||
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
|
||||||
␊
|
|
||||||
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
|
||||||
␊
|
|
||||||
::set-output name=installation-id::123456␊
|
|
||||||
␊
|
|
||||||
::set-output name=app-slug::github-actions␊
|
|
||||||
::save-state name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
|
||||||
::save-state name=expiresAt::2016-07-11T22:14:10Z␊
|
|
||||||
--- REQUESTS ---␊
|
|
||||||
GET /repos/actions/create-github-app-token/installation␊
|
|
||||||
POST /app/installations/123456/access_tokens␊
|
|
||||||
{"repositories":["create-github-app-token","toolkit","checkout"]}`
|
|
||||||
|
|
||||||
## main-token-get-owner-set-repo-set-to-many.test.js
|
|
||||||
|
|
||||||
> stderr
|
|
||||||
|
|
||||||
''
|
|
||||||
|
|
||||||
> stdout
|
|
||||||
|
|
||||||
`Inputs 'owner' and 'repositories' are set. Creating token for the following repositories:␊
|
|
||||||
␊
|
|
||||||
- actions/create-github-app-token␊
|
|
||||||
- actions/toolkit␊
|
|
||||||
- actions/checkout␊
|
|
||||||
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
|
||||||
␊
|
|
||||||
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
|
||||||
␊
|
|
||||||
::set-output name=installation-id::123456␊
|
|
||||||
␊
|
|
||||||
::set-output name=app-slug::github-actions␊
|
|
||||||
::save-state name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
|
||||||
::save-state name=expiresAt::2016-07-11T22:14:10Z␊
|
|
||||||
--- REQUESTS ---␊
|
|
||||||
GET /repos/actions/create-github-app-token/installation␊
|
|
||||||
POST /app/installations/123456/access_tokens␊
|
|
||||||
{"repositories":["create-github-app-token","toolkit","checkout"]}`
|
|
||||||
|
|
||||||
## main-token-get-owner-set-repo-set-to-one.test.js
|
|
||||||
|
|
||||||
> stderr
|
|
||||||
|
|
||||||
''
|
|
||||||
|
|
||||||
> stdout
|
|
||||||
|
|
||||||
`Inputs 'owner' and 'repositories' are set. Creating token for the following repositories:␊
|
|
||||||
␊
|
|
||||||
- actions/create-github-app-token␊
|
|
||||||
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
|
||||||
␊
|
|
||||||
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
|
||||||
␊
|
|
||||||
::set-output name=installation-id::123456␊
|
|
||||||
␊
|
|
||||||
::set-output name=app-slug::github-actions␊
|
|
||||||
::save-state name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
|
||||||
::save-state name=expiresAt::2016-07-11T22:14:10Z␊
|
|
||||||
--- REQUESTS ---␊
|
|
||||||
GET /repos/actions/create-github-app-token/installation␊
|
|
||||||
POST /app/installations/123456/access_tokens␊
|
|
||||||
{"repositories":["create-github-app-token"]}`
|
|
||||||
|
|
||||||
## main-token-get-owner-set-repo-unset.test.js
|
|
||||||
|
|
||||||
> stderr
|
|
||||||
|
|
||||||
''
|
|
||||||
|
|
||||||
> stdout
|
|
||||||
|
|
||||||
`Input 'repositories' is not set. Creating token for all repositories owned by actions.␊
|
|
||||||
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
|
||||||
␊
|
|
||||||
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
|
||||||
␊
|
|
||||||
::set-output name=installation-id::123456␊
|
|
||||||
␊
|
|
||||||
::set-output name=app-slug::github-actions␊
|
|
||||||
::save-state name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
|
||||||
::save-state name=expiresAt::2016-07-11T22:14:10Z␊
|
|
||||||
--- REQUESTS ---␊
|
|
||||||
GET /users/actions/installation␊
|
|
||||||
POST /app/installations/123456/access_tokens␊
|
|
||||||
null`
|
|
||||||
|
|
||||||
## main-token-get-owner-unset-repo-set.test.js
|
|
||||||
|
|
||||||
> stderr
|
|
||||||
|
|
||||||
''
|
|
||||||
|
|
||||||
> stdout
|
|
||||||
|
|
||||||
`No 'owner' input provided. Using default owner 'actions' to create token for the following repositories:␊
|
|
||||||
- actions/create-github-app-token␊
|
|
||||||
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
|
||||||
␊
|
|
||||||
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
|
||||||
␊
|
|
||||||
::set-output name=installation-id::123456␊
|
|
||||||
␊
|
|
||||||
::set-output name=app-slug::github-actions␊
|
|
||||||
::save-state name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
|
||||||
::save-state name=expiresAt::2016-07-11T22:14:10Z␊
|
|
||||||
--- REQUESTS ---␊
|
|
||||||
GET /repos/actions/create-github-app-token/installation␊
|
|
||||||
POST /app/installations/123456/access_tokens␊
|
|
||||||
{"repositories":["create-github-app-token"]}`
|
|
||||||
|
|
||||||
## main-token-get-owner-unset-repo-unset.test.js
|
|
||||||
|
|
||||||
> stderr
|
|
||||||
|
|
||||||
''
|
|
||||||
|
|
||||||
> stdout
|
|
||||||
|
|
||||||
`Inputs 'owner' and 'repositories' are not set. Creating token for this repository (actions/create-github-app-token).␊
|
|
||||||
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
|
||||||
␊
|
|
||||||
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
|
||||||
␊
|
|
||||||
::set-output name=installation-id::123456␊
|
|
||||||
␊
|
|
||||||
::set-output name=app-slug::github-actions␊
|
|
||||||
::save-state name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
|
||||||
::save-state name=expiresAt::2016-07-11T22:14:10Z␊
|
|
||||||
--- REQUESTS ---␊
|
|
||||||
GET /repos/actions/create-github-app-token/installation␊
|
|
||||||
POST /app/installations/123456/access_tokens␊
|
|
||||||
{"repositories":["create-github-app-token"]}`
|
|
||||||
|
|
||||||
## main-token-permissions-set.test.js
|
|
||||||
|
|
||||||
> stderr
|
|
||||||
|
|
||||||
''
|
|
||||||
|
|
||||||
> stdout
|
|
||||||
|
|
||||||
`Inputs 'owner' and 'repositories' are not set. Creating token for this repository (actions/create-github-app-token).␊
|
|
||||||
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
|
||||||
␊
|
|
||||||
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
|
||||||
␊
|
|
||||||
::set-output name=installation-id::123456␊
|
|
||||||
␊
|
|
||||||
::set-output name=app-slug::github-actions␊
|
|
||||||
::save-state name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
|
||||||
::save-state name=expiresAt::2016-07-11T22:14:10Z␊
|
|
||||||
--- REQUESTS ---␊
|
|
||||||
GET /repos/actions/create-github-app-token/installation␊
|
|
||||||
POST /app/installations/123456/access_tokens␊
|
|
||||||
{"repositories":["create-github-app-token"],"permissions":{"issues":"write","pull_requests":"read"}}`
|
|
||||||
|
|
||||||
## post-proxy-requires-native-support.test.js
|
|
||||||
|
|
||||||
> stderr
|
|
||||||
|
|
||||||
'A proxy environment variable is set, but Node.js native proxy support is not enabled. Set NODE_USE_ENV_PROXY=1 for this action step.'
|
|
||||||
|
|
||||||
> stdout
|
|
||||||
|
|
||||||
'::error::A proxy environment variable is set, but Node.js native proxy support is not enabled. Set NODE_USE_ENV_PROXY=1 for this action step.'
|
|
||||||
|
|
||||||
## post-revoke-token-fail-response.test.js
|
|
||||||
|
|
||||||
> stderr
|
|
||||||
|
|
||||||
''
|
|
||||||
|
|
||||||
> stdout
|
|
||||||
|
|
||||||
'::warning::Token revocation failed: '
|
|
||||||
|
|
||||||
## post-token-expired.test.js
|
|
||||||
|
|
||||||
> stderr
|
|
||||||
|
|
||||||
''
|
|
||||||
|
|
||||||
> stdout
|
|
||||||
|
|
||||||
'Token expired, skipping token revocation'
|
|
||||||
|
|
||||||
## post-token-set.test.js
|
|
||||||
|
|
||||||
> stderr
|
|
||||||
|
|
||||||
''
|
|
||||||
|
|
||||||
> stdout
|
|
||||||
|
|
||||||
'Token revoked'
|
|
||||||
|
|
||||||
## post-token-skipped.test.js
|
|
||||||
|
|
||||||
> stderr
|
|
||||||
|
|
||||||
''
|
|
||||||
|
|
||||||
> stdout
|
|
||||||
|
|
||||||
'Token revocation was skipped'
|
|
||||||
|
|
||||||
## post-token-unset.test.js
|
|
||||||
|
|
||||||
> stderr
|
|
||||||
|
|
||||||
''
|
|
||||||
|
|
||||||
> stdout
|
|
||||||
|
|
||||||
'Token is not set'
|
|
||||||
Binary file not shown.
Reference in New Issue
Block a user