Skip to content

Commit 9d40274

Browse files
committed
Add dry runs to CI
1 parent ce77614 commit 9d40274

13 files changed

+164
-53
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,21 @@ jobs:
3636
run: yarn lint
3737
- name: test
3838
run: yarn test
39+
publish-packages-dry-run:
40+
needs: build_and_test
41+
uses: ./.github/workflows/publish-packages.yml
42+
with:
43+
dry-run: true
44+
publish-registry-dry-run:
45+
needs: build_and_test
46+
uses: ./.github/workflows/publish-registry.yml
47+
with:
48+
dry-run: true
49+
retag-dry-run:
50+
needs: build_and_test
51+
uses: ./.github/workflows/retag.yml
52+
with:
53+
dry-run: true
3954
publish_alpha:
4055
name: publish alpha release
4156
runs-on: ubuntu-latest
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Publish packages
2+
on:
3+
workflow_call:
4+
inputs:
5+
dry-run:
6+
type: boolean
7+
workflow_dispatch:
8+
inputs:
9+
dry-run:
10+
type: boolean
11+
jobs:
12+
publish-packages:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v3
16+
- uses: actions/setup-node@v3
17+
with:
18+
cache: yarn
19+
- run: yarn install --frozen-lockfile
20+
- run: yarn build
21+
- name: Parse declarations
22+
run: yarn workspace @definitelytyped/publisher parse
23+
- uses: actions/cache@v3
24+
with:
25+
path: packages/utils/cache/
26+
key: cache-${{ github.run_id }}
27+
restore-keys: cache-
28+
- name: Calculate versions
29+
run: yarn workspace @definitelytyped/publisher calculate-versions
30+
- name: Generate packages
31+
run: yarn workspace @definitelytyped/publisher generate
32+
- name: Publish packages${{ (inputs || github.event.inputs).dry-run && ' dry run' || '' }}
33+
run: yarn workspace @definitelytyped/publisher publish-packages${{ (inputs || github.event.inputs).dry-run && ' --dry' || '' }}
34+
env:
35+
GH_API_TOKEN: ${{ secrets.GH_API_TOKEN }}
36+
NPM_TOKEN: ${{ secrets.NPM_RETAG_TOKEN }}
37+
- if: always()
38+
uses: actions/upload-artifact@v3
39+
with:
40+
name: ${{ github.job }}
41+
path: packages/definitions-parser/data/
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Publish registry
2+
on:
3+
workflow_call:
4+
inputs:
5+
dry-run:
6+
type: boolean
7+
workflow_dispatch:
8+
inputs:
9+
dry-run:
10+
type: boolean
11+
jobs:
12+
publish-registry:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v3
16+
- uses: actions/setup-node@v3
17+
with:
18+
cache: yarn
19+
- run: yarn install --frozen-lockfile
20+
- run: yarn build
21+
- name: Parse declarations
22+
run: yarn workspace @definitelytyped/publisher parse
23+
- uses: actions/cache@v3
24+
with:
25+
path: packages/utils/cache/
26+
key: cache-${{ github.run_id }}
27+
restore-keys: cache-
28+
- name: Publish registry${{ (inputs || github.event.inputs).dry-run && ' dry run' || '' }}
29+
run: yarn workspace @definitelytyped/publisher publish-registry${{ (inputs || github.event.inputs).dry-run && ' --dry' || '' }}
30+
env:
31+
NPM_TOKEN: ${{ secrets.NPM_RETAG_TOKEN }}
32+
- if: always()
33+
uses: actions/upload-artifact@v3
34+
with:
35+
name: ${{ github.job }}
36+
path: packages/definitions-parser/data/

.github/workflows/retag.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Update npm tags
2+
on:
3+
schedule:
4+
# https://crontab.guru/#0_0_*_*_0
5+
- cron: 0 0 * * 0
6+
workflow_call:
7+
inputs:
8+
dry-run:
9+
type: boolean
10+
workflow_dispatch:
11+
inputs:
12+
dry-run:
13+
type: boolean
14+
jobs:
15+
retag:
16+
if: github.event_name != 'schedule' || github.repository == 'microsoft/DefinitelyTyped-tools'
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v3
20+
- uses: actions/setup-node@v3
21+
with:
22+
cache: yarn
23+
- run: yarn install --frozen-lockfile
24+
- run: yarn build
25+
- uses: actions/cache@v3
26+
with:
27+
path: packages/utils/cache/
28+
key: cache-${{ github.run_id }}
29+
restore-keys: cache-
30+
- name: Update npm tags${{ (inputs || github.event.inputs).dry-run && ' dry run' || '' }}
31+
run: yarn retag${{ (inputs || github.event.inputs).dry-run && ' --dry' || '' }}
32+
env:
33+
NPM_TOKEN: ${{ secrets.NPM_RETAG_TOKEN }}
34+
- if: always()
35+
uses: actions/upload-artifact@v3
36+
with:
37+
name: ${{ github.job }}
38+
path: packages/definitions-parser/data/

.github/workflows/update-ts-version-tags.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"format": "prettier --write 'packages/**/*.ts'",
1212
"test": "jest",
1313
"build": "tsc -b .",
14-
"retag": "node packages/retag/dist/retag.js"
14+
"retag": "node --require source-map-support/register packages/retag/"
1515
},
1616
"devDependencies": {
1717
"@types/jest": "^25.1.3",

packages/publisher/src/calculate-versions.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { defaultLocalOptions } from "./lib/common";
1+
import * as process from "process";
2+
import { defaultLocalOptions, defaultRemoteOptions } from "./lib/common";
23
import { ChangedPackages, ChangedPackagesJson, ChangedTypingJson, versionsFilename } from "./lib/versions";
34
import { getDefinitelyTyped, AllPackages, NotNeededPackage, writeDataFile } from "@definitelytyped/definitions-parser";
45
import {
@@ -18,7 +19,11 @@ import { cacheDirPath } from "./lib/settings";
1819
if (!module.parent) {
1920
const log = loggerWithErrors()[0];
2021
logUncaughtErrors(async () =>
21-
calculateVersions(await getDefinitelyTyped(defaultLocalOptions, log), new UncachedNpmInfoClient(), log)
22+
calculateVersions(
23+
await getDefinitelyTyped(process.env.GITHUB_ACTIONS ? defaultRemoteOptions : defaultLocalOptions, log),
24+
new UncachedNpmInfoClient(),
25+
log
26+
)
2227
);
2328
}
2429

packages/publisher/src/generate-packages.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import { makeTypesVersionsForPackageJson } from "@definitelytyped/header-parser"
22
import assert = require("assert");
33
import { emptyDir, mkdir, mkdirp, readFileSync } from "fs-extra";
44
import path = require("path");
5+
import * as process from "process";
56
import yargs = require("yargs");
67

7-
import { defaultLocalOptions } from "./lib/common";
8+
import { defaultLocalOptions, defaultRemoteOptions } from "./lib/common";
89
import { outputDirPath, sourceBranch, cacheDirPath } from "./lib/settings";
910
import {
1011
assertNever,
@@ -44,7 +45,7 @@ if (!module.parent) {
4445
const tgz = !!yargs.argv.tgz;
4546
logUncaughtErrors(async () => {
4647
const log = loggerWithErrors()[0];
47-
const dt = await getDefinitelyTyped(defaultLocalOptions, log);
48+
const dt = await getDefinitelyTyped(process.env.GITHUB_ACTIONS ? defaultRemoteOptions : defaultLocalOptions, log);
4849
const allPackages = await AllPackages.read(dt);
4950
await generatePackages(dt, allPackages, await readChangedPackages(allPackages), tgz);
5051
});

packages/publisher/src/parse-definitions.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import os from "os";
2+
import * as process from "process";
23
import yargs from "yargs";
34
import { logUncaughtErrors, loggerWithErrors, assertDefined, FS } from "@definitelytyped/utils";
4-
import { defaultLocalOptions } from "./lib/common";
5+
import { defaultLocalOptions, defaultRemoteOptions } from "./lib/common";
56
import { getTypingInfo } from "@definitelytyped/definitions-parser/dist/lib/definition-parser";
67
import {
78
getDefinitelyTyped,
@@ -16,7 +17,7 @@ if (!module.parent) {
1617
nProcesses: { type: "number" },
1718
}).argv;
1819

19-
const options = defaultLocalOptions;
20+
const options = process.env.GITHUB_ACTIONS ? defaultRemoteOptions : defaultLocalOptions;
2021
logUncaughtErrors(async () => {
2122
const log = loggerWithErrors()[0];
2223
const dt = await getDefinitelyTyped(options, log);

packages/publisher/src/publish-packages.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import * as process from "process";
12
import applicationinsights = require("applicationinsights");
23
import * as yargs from "yargs";
34

4-
import { defaultLocalOptions } from "./lib/common";
5+
import { defaultLocalOptions, defaultRemoteOptions } from "./lib/common";
56
import { deprecateNotNeededPackage, publishNotNeededPackage, publishTypingsPackage } from "./lib/package-publisher";
67
import { getDefinitelyTyped, AllPackages } from "@definitelytyped/definitions-parser";
78
import {
@@ -23,7 +24,10 @@ if (!module.parent) {
2324
const dry = !!yargs.argv.dry;
2425
const deprecateName = yargs.argv.deprecate as string | undefined;
2526
logUncaughtErrors(async () => {
26-
const dt = await getDefinitelyTyped(defaultLocalOptions, loggerWithErrors()[0]);
27+
const dt = await getDefinitelyTyped(
28+
process.env.GITHUB_ACTIONS ? defaultRemoteOptions : defaultLocalOptions,
29+
loggerWithErrors()[0]
30+
);
2731
if (deprecateName !== undefined) {
2832
// A '--deprecate' command is available in case types-publisher got stuck *while* trying to deprecate a package.
2933
// Normally this should not be needed.
@@ -59,7 +63,7 @@ export default async function publishPackages(
5963
log("=== Publishing packages ===");
6064
}
6165

62-
const client = await NpmPublishClient.create(await getSecret(Secret.NPM_TOKEN), undefined);
66+
const client = await NpmPublishClient.create(dry ? "" : await getSecret(Secret.NPM_TOKEN), undefined);
6367

6468
for (const cp of changedPackages.changedTypings) {
6569
log(`Publishing ${cp.pkg.desc}...`);

0 commit comments

Comments
 (0)