-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add timezone update workflow #43988
Merged
Merged
Add timezone update workflow #43988
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
564e813
tools: add skeleton for automate time zone update
98lenvi eaa919e
tools: apply 2022a timezone patch on icu file
98lenvi 50b226f
tools: get latest tz version
98lenvi 17ac322
tools: apply suggestions
98lenvi 2cbc9cb
tools: move icu-data clone to worker
98lenvi b84bec3
tools: fix action
98lenvi dc093e3
tools: fix logic for getting latest ver
98lenvi 9edafa0
tools: update workflow files with suggestions
98lenvi 5f7872f
tools: update tool file with suggestion
98lenvi 5901660
tools: update reading available ver to readdirSync
98lenvi c9feb95
tools: update cleaning to rmSync
98lenvi d8015a7
tools: apply suggestions
98lenvi f61c886
fix: update commit message + logs
98lenvi be1d5bd
fix: run linter fixes
98lenvi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Timezone update | ||
on: | ||
schedule: | ||
# Run once a week at 00:05 AM UTC on Sunday. | ||
- cron: 5 0 * * 0 | ||
|
||
workflow_dispatch: | ||
|
||
jobs: | ||
timezone_update: | ||
if: github.repository == 'nodejs/node' | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout nodejs/node | ||
uses: actions/checkout@v3 | ||
with: | ||
persist-credentials: false | ||
|
||
- name: Checkout unicode-org/icu-data | ||
uses: actions/checkout@v3 | ||
with: | ||
path: icu-data | ||
persist-credentials: false | ||
repository: unicode-org/icu-data | ||
|
||
- run: ./tools/update-timezone.mjs | ||
|
||
- name: Open Pull Request | ||
uses: gr2m/create-or-update-pull-request-action@6720400cad8e74d7adc64640e4e6ea6748b83d8f # Create a PR or update the Action's existing PR | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_USER_TOKEN }} | ||
with: | ||
author: Node.js GitHub Bot <[email protected]> | ||
body: | | ||
This PR was generated by tools/timezone-update.yml. | ||
Updates the ICU files as per the instructions present in https://github.com/nodejs/node/blob/main/doc/contributing/maintaining-icu.md#time-zone-data | ||
To test, build node off this branch & log the version of tz using | ||
```js | ||
console.log(process.versions.tz) | ||
``` | ||
branch: actions/timezone-update | ||
commit-message: 'deps: update timezone' | ||
labels: dependencies | ||
title: 'deps: update timezone' | ||
reviewers: \@nodejs/i18n-api |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env node | ||
// Usage: tools/update-timezone.mjs | ||
import { execSync, spawnSync } from 'node:child_process'; | ||
import { renameSync, readdirSync, rmSync } from 'node:fs'; | ||
import { exit } from 'node:process'; | ||
|
||
const fileNames = [ | ||
'zoneinfo64.res', | ||
'windowsZones.res', | ||
'timezoneTypes.res', | ||
'metaZones.res', | ||
]; | ||
|
||
const availableVersions = readdirSync('icu-data/tzdata/icunew', { withFileTypes: true }) | ||
.filter((dirent) => dirent.isDirectory()) | ||
.map((dirent) => dirent.name); | ||
|
||
const currentVersion = process.versions.tz; | ||
const latestVersion = availableVersions.sort().at(-1); | ||
|
||
if (latestVersion === currentVersion) { | ||
console.log(`Terminating early, tz version is latest @ ${currentVersion}`); | ||
exit(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should print something here to note the reason for exitting |
||
} | ||
|
||
execSync('bzip2 -d deps/icu-small/source/data/in/icudt*.dat.bz2'); | ||
fileNames.forEach((file) => { | ||
renameSync(`icu-data/tzdata/icunew/${latestVersion}/44/le/${file}`, `deps/icu-small/source/data/in/${file}`); | ||
spawnSync( | ||
'icupkg', [ | ||
'-a', | ||
file, | ||
'icudt*.dat', | ||
], { cwd: 'deps/icu-small/source/data/in/' } | ||
); | ||
rmSync(`deps/icu-small/source/data/in/${file}`); | ||
}); | ||
execSync('bzip2 -z deps/icu-small/source/data/in/icudt*.dat'); | ||
rmSync('icu-data', { recursive: true }); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these releases are so infrequent, max 5 times a year. Probably better to just run on workflow dispatch.
If you do want to check weekly, it might be better to use caching and cache the icu-data checkout, and then do an update. Maybe there's some other way to trigger this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @srl295. I'm a bit confused about the caching. Every time we run this we want to ensure that we are fetching the latest data from ICU upstream & then find if we have something new in the repo.
I'll just change it to workflow dispatch/manually trigerred.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's manually, we might miss the updates & only know when someone reports that a new version is out. The goal of this PR was to have the workflow tell us that a new version is out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think having it run weekly is OK if we don't have any other way to trigger it when there's actually an update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I meant is if the repository was cached it wouldn't have to redownload every time.
@yumaoka are updates always mentioned on icu-announce? If so then subscribers to that wouldn't miss it.