Compare commits

...

3 Commits

Author SHA1 Message Date
Taiki Endo
bb478bb090 Release 2.41.1 2024-06-22 12:44:37 +09:00
Jiahao XU
4558bb807b Speedup codegen by caching tools/codegen compilation (#554) 2024-06-22 12:43:03 +09:00
Taiki Endo
315e996a95 Update typos@latest to 1.22.8 2024-06-22 07:02:08 +09:00
5 changed files with 65 additions and 28 deletions

View File

@@ -83,6 +83,8 @@ jobs:
- uses: ./
with:
tool: ${{ steps.tool-list.outputs.tool }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell
- name: Test bash
run: just --version && shfmt --version && protoc --version
@@ -151,6 +153,8 @@ jobs:
- uses: ./
with:
tool: ${{ steps.tool-list.outputs.tool }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
manifest:
runs-on: ubuntu-latest
@@ -161,7 +165,12 @@ jobs:
steps:
- uses: taiki-e/checkout-action@v1
- name: Install Rust
run: rustup toolchain add nightly --no-self-update && rustup default nightly
run: rustup update stable --no-self-update
- name: Generate Cargo.lock
run: cargo update
- uses: Swatinem/rust-cache@v2
with:
cache-all-crates: 'true'
- run: tools/manifest.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -10,6 +10,10 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com
## [Unreleased]
## [2.41.1] - 2024-06-22
- Update `typos@latest` to 1.22.8.
## [2.41.0] - 2024-06-21
- Support `knope`. ([#553](https://github.com/taiki-e/install-action/pull/553), thanks @jayvdb)
@@ -2376,7 +2380,8 @@ Note: This release is considered a breaking change because installing on version
Initial release
[Unreleased]: https://github.com/taiki-e/install-action/compare/v2.41.0...HEAD
[Unreleased]: https://github.com/taiki-e/install-action/compare/v2.41.1...HEAD
[2.41.1]: https://github.com/taiki-e/install-action/compare/v2.41.0...v2.41.1
[2.41.0]: https://github.com/taiki-e/install-action/compare/v2.40.2...v2.41.0
[2.40.2]: https://github.com/taiki-e/install-action/compare/v2.40.1...v2.40.2
[2.40.1]: https://github.com/taiki-e/install-action/compare/v2.40.0...v2.40.1

24
manifests/typos.json generated
View File

@@ -16,13 +16,31 @@
},
"license_markdown": "[MIT](https://github.com/crate-ci/typos/blob/master/LICENSE-MIT) OR [Apache-2.0](https://github.com/crate-ci/typos/blob/master/LICENSE-APACHE)",
"latest": {
"version": "1.22.7"
"version": "1.22.8"
},
"1": {
"version": "1.22.7"
"version": "1.22.8"
},
"1.22": {
"version": "1.22.7"
"version": "1.22.8"
},
"1.22.8": {
"x86_64_linux_musl": {
"etag": "0x8DC9221550C37C8",
"checksum": "4f919cc3a8ce9d0290e0d7923893dcdc37f3e5c7e29ed1f360484e35c2ec560b"
},
"x86_64_macos": {
"etag": "0x8DC92217C08D7BD",
"checksum": "bfc6d0369c4ec8e5d24a58d7ee0f4fd05c14f5de7506cf1cbd2c3d0742ff06fa"
},
"x86_64_windows": {
"etag": "0x8DC9221705C4AA4",
"checksum": "a0e1a80c2d6bf6226a20648cb82a58b0b272a0f414491d93b3a18a692f5b8d42"
},
"aarch64_macos": {
"etag": "0x8DC922172FCD647",
"checksum": "4a5677d83d72a93a25f426fab39ec9c747d47b8de25323bd2cf8fcad90a49ce1"
}
},
"1.22.7": {
"x86_64_linux_musl": {

View File

@@ -7,7 +7,7 @@ use std::{
ffi::OsStr,
io::Read,
path::Path,
sync::{LazyLock, RwLock},
sync::{OnceLock, RwLock},
time::Duration,
};
@@ -649,38 +649,43 @@ struct GitHubTokens {
other: RwLock<Option<String>>,
}
impl GitHubTokens {
fn get(&self, url: &str) -> Option<String> {
// TODO: Use std::sync::LazyLock once 1.80 is released
fn get_github_tokens() -> &'static GitHubTokens {
static GITHUB_TOKENS: OnceLock<GitHubTokens> = OnceLock::new();
GITHUB_TOKENS.get_or_init(|| {
let token = env::var("GITHUB_TOKEN").ok().filter(|v| !v.is_empty());
GitHubTokens {
raw: RwLock::new(token.clone()),
api: RwLock::new(token.clone()),
other: RwLock::new(token),
}
})
}
fn get(url: &str) -> Option<String> {
if url.starts_with("https://raw.githubusercontent.com/") {
self.raw.read().unwrap().clone()
Self::get_github_tokens().raw.read().unwrap().clone()
} else if url.starts_with("https://api.github.com/") {
self.api.read().unwrap().clone()
Self::get_github_tokens().api.read().unwrap().clone()
} else if url.starts_with("https://github.com/") {
self.other.read().unwrap().clone()
Self::get_github_tokens().other.read().unwrap().clone()
} else {
None
}
}
fn clear(&self, url: &str) {
fn clear(url: &str) {
if url.starts_with("https://raw.githubusercontent.com/") {
*self.raw.write().unwrap() = None;
*Self::get_github_tokens().raw.write().unwrap() = None;
} else if url.starts_with("https://api.github.com/") {
*self.api.write().unwrap() = None;
*Self::get_github_tokens().api.write().unwrap() = None;
} else if url.starts_with("https://github.com/") {
*self.other.write().unwrap() = None;
*Self::get_github_tokens().other.write().unwrap() = None;
}
}
}
static GITHUB_TOKENS: LazyLock<GitHubTokens> = LazyLock::new(|| {
let token = env::var("GITHUB_TOKEN").ok().filter(|v| !v.is_empty());
GitHubTokens {
raw: RwLock::new(token.clone()),
api: RwLock::new(token.clone()),
other: RwLock::new(token),
}
});
fn download(url: &str) -> Result<ureq::Response> {
let mut token = GITHUB_TOKENS.get(url);
let mut token = GitHubTokens::get(url);
let mut retry = 0;
let mut retry_time = 0;
let mut max_retry = 6;
@@ -702,7 +707,7 @@ fn download(url: &str) -> Result<ureq::Response> {
retry_time = 0;
token = None;
// rate limit
GITHUB_TOKENS.clear(url);
GitHubTokens::clear(url);
}
retry += 1;
if retry > max_retry {
@@ -716,7 +721,7 @@ fn download(url: &str) -> Result<ureq::Response> {
fn github_head(url: &str) -> Result<()> {
eprintln!("fetching head of {url} ..");
let mut token = GITHUB_TOKENS.get(url);
let mut token = GitHubTokens::get(url);
let mut retry = 0;
let mut retry_time = 0;
let mut max_retry = 2;
@@ -739,7 +744,7 @@ fn github_head(url: &str) -> Result<()> {
if token.is_some() && retry == max_retry / 2 {
retry_time = 0;
token = None;
GITHUB_TOKENS.clear(url);
GitHubTokens::clear(url);
}
retry += 1;
if retry > max_retry {

View File

@@ -10,11 +10,11 @@ cd "$(dirname "$0")"/..
# ./tools/manifest.sh [PACKAGE [VERSION_REQ]]
if [[ $# -gt 0 ]]; then
cargo +nightly run --manifest-path tools/codegen/Cargo.toml --release -- "$@"
cargo run --manifest-path tools/codegen/Cargo.toml --release -- "$@"
exit 0
fi
for manifest in tools/codegen/base/*.json; do
package=$(basename "${manifest%.*}")
cargo +nightly run --manifest-path tools/codegen/Cargo.toml --release -- "${package}" latest
cargo run --manifest-path tools/codegen/Cargo.toml --release -- "${package}" latest
done