Skip to content

Commit 9637a93

Browse files
committed
Add dry runs to CI
1 parent 8139e13 commit 9637a93

15 files changed

+189
-97
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: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { defaultLocalOptions } from "./lib/common";
1+
import 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 {
@@ -13,12 +14,15 @@ import {
1314
CachedNpmInfoClient,
1415
} from "@definitelytyped/utils";
1516
import { fetchTypesPackageVersionInfo } from "@definitelytyped/retag";
16-
import { cacheDirPath } from "./lib/settings";
1717

1818
if (!module.parent) {
1919
const log = loggerWithErrors()[0];
2020
logUncaughtErrors(async () =>
21-
calculateVersions(await getDefinitelyTyped(defaultLocalOptions, log), new UncachedNpmInfoClient(), log)
21+
calculateVersions(
22+
await getDefinitelyTyped(process.env.GITHUB_ACTIONS ? defaultRemoteOptions : defaultLocalOptions, log),
23+
new UncachedNpmInfoClient(),
24+
log
25+
)
2226
);
2327
}
2428

@@ -28,15 +32,11 @@ export default async function calculateVersions(
2832
log: LoggerWithErrors
2933
): Promise<ChangedPackages> {
3034
log.info("=== Calculating versions ===");
31-
return withNpmCache(
32-
uncachedClient,
33-
async (client) => {
34-
log.info("* Reading packages...");
35-
const packages = await AllPackages.read(dt);
36-
return computeAndSaveChangedPackages(packages, log, client);
37-
},
38-
cacheDirPath
39-
);
35+
return withNpmCache(uncachedClient, async (client) => {
36+
log.info("* Reading packages...");
37+
const packages = await AllPackages.read(dt);
38+
return computeAndSaveChangedPackages(packages, log, client);
39+
});
4040
}
4141

4242
async function computeAndSaveChangedPackages(

packages/publisher/src/generate-packages.ts

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ 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 process from "process";
56
import yargs = require("yargs");
67

7-
import { defaultLocalOptions } from "./lib/common";
8-
import { outputDirPath, sourceBranch, cacheDirPath } from "./lib/settings";
8+
import { defaultLocalOptions, defaultRemoteOptions } from "./lib/common";
9+
import { outputDirPath, sourceBranch } from "./lib/settings";
910
import {
1011
assertNever,
1112
joinPaths,
@@ -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
});
@@ -70,16 +71,12 @@ export default async function generatePackages(
7071
log(` * ${pkg.desc}`);
7172
}
7273
log("## Generating deprecated packages");
73-
await withNpmCache(
74-
new UncachedNpmInfoClient(),
75-
async (client) => {
76-
for (const pkg of changedPackages.changedNotNeededPackages) {
77-
log(` * ${pkg.libraryName}`);
78-
await generateNotNeededPackage(pkg, client, log);
79-
}
80-
},
81-
cacheDirPath
82-
);
74+
await withNpmCache(new UncachedNpmInfoClient(), async (client) => {
75+
for (const pkg of changedPackages.changedNotNeededPackages) {
76+
log(` * ${pkg.libraryName}`);
77+
await generateNotNeededPackage(pkg, client, log);
78+
}
79+
});
8380
await writeLog("package-generator.md", logResult());
8481
}
8582
async function generateTypingPackage(

packages/publisher/src/lib/settings.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { toS } from "hh-mm-ss";
44
const hostJson = require("../../host.json");
55
const root = joinPaths(__dirname, "..", "..");
66
const storageDirPath = process.env.STORAGE_DIR || root;
7-
export const cacheDirPath = joinPaths(storageDirPath, "cache");
87
export const outputDirPath = joinPaths(storageDirPath, "output");
98
export const validateOutputPath = joinPaths(storageDirPath, "validateOutput");
109
export const logDir = joinPaths(storageDirPath, "logs");

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 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);

0 commit comments

Comments
 (0)