Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions .github/workflow-scripts/__tests__/createDraftRelease-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ View the whole changelog in the [CHANGELOG.md file](https://github.com/facebook/
status: 201,
json: () =>
Promise.resolve({
id: 1,
html_url:
'https://github.com/facebook/react-native/releases/tag/v0.77.1',
}),
Expand All @@ -208,9 +209,11 @@ View the whole changelog in the [CHANGELOG.md file](https://github.com/facebook/
body: fetchBody,
},
);
expect(response).toEqual(
'https://github.com/facebook/react-native/releases/tag/v0.77.1',
);
expect(response).toEqual({
id: 1,
html_url:
'https://github.com/facebook/react-native/releases/tag/v0.77.1',
});
});

it('creates a draft release for prerelease on GitHub', async () => {
Expand Down Expand Up @@ -238,6 +241,7 @@ View the whole changelog in the [CHANGELOG.md file](https://github.com/facebook/
status: 201,
json: () =>
Promise.resolve({
id: 1,
html_url:
'https://github.com/facebook/react-native/releases/tag/v0.77.1',
}),
Expand All @@ -258,9 +262,11 @@ View the whole changelog in the [CHANGELOG.md file](https://github.com/facebook/
body: fetchBody,
},
);
expect(response).toEqual(
'https://github.com/facebook/react-native/releases/tag/v0.77.1',
);
expect(response).toEqual({
id: 1,
html_url:
'https://github.com/facebook/react-native/releases/tag/v0.77.1',
});
});

it('throws if the post failes', async () => {
Expand Down
9 changes: 7 additions & 2 deletions .github/workflow-scripts/createDraftRelease.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ async function _createDraftReleaseOnGitHub(version, body, latest, token) {
}

const data = await response.json();
return data.html_url;
const {html_url, id} = data;
return {
html_url,
id,
};
}

function moveToChangelogBranch(version) {
Expand All @@ -124,7 +128,8 @@ async function createDraftRelease(version, latest, token) {
latest,
token,
);
log(`Created draft release: ${release}`);
log(`Created draft release: ${release.html_url}, ID ${release.id}`);
return release;
}

module.exports = {
Expand Down
17 changes: 16 additions & 1 deletion .github/workflows/create-draft-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,24 @@ jobs:
git config --local user.name "React Native Bot"
- name: Create draft release
uses: actions/github-script@v6
id: create-draft-release
with:
script: |
const {createDraftRelease} = require('./.github/workflow-scripts/createDraftRelease.js');
const version = '${{ github.ref_name }}';
const {isLatest} = require('./.github/workflow-scripts/publishTemplate.js');
await createDraftRelease(version, isLatest(), '${{secrets.REACT_NATIVE_BOT_GITHUB_TOKEN}}');
return (await createDraftRelease(version, isLatest(), '${{secrets.REACT_NATIVE_BOT_GITHUB_TOKEN}}')).id;
result-encoding: string
- name: Upload release assets for DotSlash
uses: actions/github-script@v6
env:
RELEASE_ID: ${{ steps.create-draft-release.outputs.result }}
with:
script: |
const {uploadReleaseAssetsForDotSlashFiles} = require('./scripts/releases/upload-release-assets-for-dotslash.js');
const version = '${{ github.ref_name }}';
await uploadReleaseAssetsForDotSlashFiles({
version,
token: '${{secrets.REACT_NATIVE_BOT_GITHUB_TOKEN}}',
releaseId: process.env.RELEASE_ID,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
releaseId: process.env.RELEASE_ID,
releaseId: ${{ steps.create-draft-release.outputs.result }}

});
48 changes: 48 additions & 0 deletions .github/workflows/validate-dotslash-artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Validate DotSlash Artifacts

on:
workflow_dispatch:
release:
types: [published]
push:
branches:
- main
Comment on lines +7 to +9
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels wrong, are you sure about it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It turns out it's correct. Still I'm not 100% sure why we would need to run a continous validation of the dotslash artifacts. Specifically, this is a job that will run on main (also, why not on PRs also then) and that is heavily dependent on network, so it could result in a lot of red signals for us

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running on PRs targeting main is reasonable - it's just largely unnecessary, because we're only going to be touching the DotSlash files in bot commits that will be auto-landed in fbsource and then exported to the main branch.

To reduce the false positive rate, we could narrow this down further to commits that actually touch the DotSlash file(s), though of course that could miss infra changes in the repo that might break the workflow.

The scenario I'm trying to prevent is one where our internal binary publishing pipeline / CDN gets broken and stops being accessible from OSS, but we only find out extremely late, when we try to create a release commit. (As explained in the summary, we can't run the validation continuously in the branch because it would fail - by design - between pushing the release commit and publishing the release).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(As explained in the summary, we can't run the validation continuously in the branch because it would fail - by design - between pushing the release commit and publishing the release).

Let's let it run only on *-stable branches then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's let it run only on *-stable branches then?

That's not feasible, unless we're OK with letting the job fail on release commits (and in fact tagging the release on a commit that has red CI signals!)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scenario I'm trying to prevent is one where our internal binary publishing pipeline / CDN gets broken and stops being accessible from OSS, but we only find out extremely late, when we try to create a release commit.

Hmm, what about on nightlies instead?

Copy link
Contributor Author

@motiz88 motiz88 Sep 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh interesting. I don't know that we want to block nightlies on this - doesn't look like we do so when another kind of test is broken - but I'm definitely open to making this a scheduled job for periodic validation, plus running on pushes+PRs that touch the actual DotSlash file and related infra. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See 5b02181.

paths:
- packages/debugger-shell/bin/react-native-devtools
- "scripts/releases/**"
- package.json
- yarn.lock
pull_request:
branches:
- main
paths:
- packages/debugger-shell/bin/react-native-devtools
- "scripts/releases/**"
- package.json
- yarn.lock
# Same time as the nightly build: 2:15 AM UTC
schedule:
- cron: "15 2 * * *"

jobs:
validate-dotslash-artifacts:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Install dependencies
uses: ./.github/actions/yarn-install
- name: Configure Git
shell: bash
run: |
git config --local user.email "bot@reactnative.dev"
git config --local user.name "React Native Bot"
- name: Validate DotSlash artifacts
uses: actions/github-script@v6
with:
script: |
const {validateDotSlashArtifacts} = require('./scripts/releases/validate-dotslash-artifacts.js');
await validateDotSlashArtifacts();
46 changes: 46 additions & 0 deletions flow-typed/npm/@expo/spawn-async_v1.x.x.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/

declare module '@expo/spawn-async' {
type SpawnOptions = {
cwd?: string,
env?: Object,
argv0?: string,
stdio?: string | Array<any>,
detached?: boolean,
uid?: number,
gid?: number,
shell?: boolean | string,
windowsVerbatimArguments?: boolean,
windowsHide?: boolean,
encoding?: string,
ignoreStdio?: boolean,
};

declare class SpawnPromise<T> extends Promise<T> {
child: child_process$ChildProcess;
}
type SpawnResult = {
pid?: number,
output: string[],
stdout: string,
stderr: string,
status: number | null,
signal: string | null,
};

declare function spawnAsync(
command: string,
args?: $ReadOnlyArray<string>,
options?: SpawnOptions,
): SpawnPromise<SpawnResult>;

declare module.exports: typeof spawnAsync;
}
61 changes: 61 additions & 0 deletions flow-typed/npm/@octokit/rest_v22.x.x.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/

// Partial types for Octokit based on the usage in react-native-github
declare module '@octokit/rest' {
declare class Octokit {
constructor(options?: {auth?: string, ...}): this;

repos: $ReadOnly<{
listReleaseAssets: (
params: $ReadOnly<{
owner: string,
repo: string,
release_id: string,
}>,
) => Promise<{
data: Array<{
id: string,
name: string,
...
}>,
...
}>,
uploadReleaseAsset: (
params: $ReadOnly<{
owner: string,
repo: string,
release_id: string,
name: string,
data: Buffer,
headers: $ReadOnly<{
'content-type': string,
...
}>,
...
}>,
) => Promise<{
data: {
browser_download_url: string,
...
},
...
}>,
deleteReleaseAsset: (params: {
owner: string,
repo: string,
asset_id: string,
...
}) => Promise<mixed>,
}>;
}

declare export {Octokit};
}
13 changes: 13 additions & 0 deletions flow-typed/npm/fb-dotslash_v0.x.x.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/

declare module 'fb-dotslash' {
declare module.exports: string;
}
Loading
Loading