mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 07:14:47 -05:00
ci: actually fix workflow permissions (#22644)
Also adds a lint to ensure this file is kept up to date.
This commit is contained in:
parent
878384aefa
commit
7ac0408330
3 changed files with 38 additions and 14 deletions
24
.github/workflows/ci.generate.ts
vendored
24
.github/workflows/ci.generate.ts
vendored
|
@ -301,6 +301,9 @@ function handleMatrixItems(items: {
|
|||
|
||||
const ci = {
|
||||
name: "ci",
|
||||
permissions: {
|
||||
contents: "write",
|
||||
},
|
||||
on: {
|
||||
push: {
|
||||
branches: ["main"],
|
||||
|
@ -1075,11 +1078,18 @@ const ci = {
|
|||
},
|
||||
};
|
||||
|
||||
let finalText = `# GENERATED BY ./ci.generate.ts -- DO NOT DIRECTLY EDIT\n\n`;
|
||||
finalText += yaml.stringify(ci, {
|
||||
noRefs: true,
|
||||
lineWidth: 10_000,
|
||||
noCompatMode: true,
|
||||
});
|
||||
export function generate() {
|
||||
let finalText = `# GENERATED BY ./ci.generate.ts -- DO NOT DIRECTLY EDIT\n\n`;
|
||||
finalText += yaml.stringify(ci, {
|
||||
noRefs: true,
|
||||
lineWidth: 10_000,
|
||||
noCompatMode: true,
|
||||
});
|
||||
return finalText;
|
||||
}
|
||||
|
||||
Deno.writeTextFileSync(new URL("./ci.yml", import.meta.url), finalText);
|
||||
export const CI_YML_URL = new URL("./ci.yml", import.meta.url);
|
||||
|
||||
if (import.meta.main) {
|
||||
Deno.writeTextFileSync(CI_YML_URL, generate());
|
||||
}
|
||||
|
|
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
|
@ -1,6 +1,8 @@
|
|||
# GENERATED BY ./ci.generate.ts -- DO NOT DIRECTLY EDIT
|
||||
|
||||
name: ci
|
||||
permissions:
|
||||
contents: write
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
import { buildMode, getPrebuilt, getSources, join, ROOT_PATH } from "./util.js";
|
||||
import { checkCopyright } from "./copyright_checker.js";
|
||||
import * as ciFile from "../.github/workflows/ci.generate.ts";
|
||||
|
||||
const promises = [];
|
||||
|
||||
|
@ -12,17 +13,18 @@ if (!js && !rs) {
|
|||
rs = true;
|
||||
}
|
||||
|
||||
if (js) {
|
||||
promises.push(dlint());
|
||||
promises.push(dlintPreferPrimordials());
|
||||
}
|
||||
|
||||
if (rs) {
|
||||
promises.push(clippy());
|
||||
}
|
||||
|
||||
if (js && rs) {
|
||||
promises.push(checkCopyright());
|
||||
if (js) {
|
||||
promises.push(dlint());
|
||||
promises.push(dlintPreferPrimordials());
|
||||
promises.push(ensureCiYmlUpToDate());
|
||||
|
||||
if (rs) {
|
||||
promises.push(checkCopyright());
|
||||
}
|
||||
}
|
||||
|
||||
const results = await Promise.allSettled(promises);
|
||||
|
@ -164,3 +166,13 @@ async function clippy() {
|
|||
throw new Error("clippy failed");
|
||||
}
|
||||
}
|
||||
|
||||
async function ensureCiYmlUpToDate() {
|
||||
const expectedCiFileText = ciFile.generate();
|
||||
const actualCiFileText = await Deno.readTextFile(ciFile.CI_YML_URL);
|
||||
if (expectedCiFileText !== actualCiFileText) {
|
||||
throw new Error(
|
||||
"./.github/workflows/ci.yml is out of date. Run: ./.github/workflows/ci.generate.ts",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue