From 9eef09dbef799abe9a3517340fb6230dfe8e3c44 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Sun, 6 Feb 2022 14:29:21 +0900 Subject: [PATCH 1/3] Clean up ci/no_atomic_cas.sh --- ci/no_atomic_cas.sh | 35 +++++++++++++++++++---------------- futures-channel/build.rs | 2 +- futures-core/build.rs | 2 +- futures-task/build.rs | 2 +- futures-util/build.rs | 2 +- no_atomic_cas.rs | 2 +- 6 files changed, 24 insertions(+), 21 deletions(-) diff --git a/ci/no_atomic_cas.sh b/ci/no_atomic_cas.sh index 40b2f1b90b..ba0200d698 100755 --- a/ci/no_atomic_cas.sh +++ b/ci/no_atomic_cas.sh @@ -1,28 +1,31 @@ #!/bin/bash +set -euo pipefail +IFS=$'\n\t' +cd "$(dirname "$0")"/.. # Update the list of targets that do not support atomic CAS operations. # # Usage: # ./ci/no_atomic_cas.sh -set -euo pipefail -IFS=$'\n\t' - -cd "$(cd "$(dirname "$0")" && pwd)"/.. - file="no_atomic_cas.rs" -{ - echo "// This file is @generated by $(basename "$0")." - echo "// It is not intended for manual editing." - echo "" - echo "const NO_ATOMIC_CAS_TARGETS: &[&str] = &[" -} >"$file" - +no_atomic_cas=() for target in $(rustc --print target-list); do - res=$(rustc --print target-spec-json -Z unstable-options --target "$target" \ - | jq -r "select(.\"atomic-cas\" == false)") - [[ -z "$res" ]] || echo " \"$target\"," >>"$file" + target_spec=$(rustc --print target-spec-json -Z unstable-options --target "${target}") + res=$(jq <<<"${target_spec}" -r 'select(."atomic-cas" == false)') + [[ -z "${res}" ]] || no_atomic_cas+=("${target}") done -echo "];" >>"$file" +cat >"${file}" <>"${file}" +done +cat >>"${file}" < Date: Sun, 6 Feb 2022 14:31:50 +0900 Subject: [PATCH 2/3] Update comments in build scripts --- futures-channel/build.rs | 19 +++++++++---------- futures-core/build.rs | 19 +++++++++---------- futures-task/build.rs | 19 +++++++++---------- futures-util/build.rs | 19 +++++++++---------- 4 files changed, 36 insertions(+), 40 deletions(-) diff --git a/futures-channel/build.rs b/futures-channel/build.rs index 6fd1ebdabf..05e0496d94 100644 --- a/futures-channel/build.rs +++ b/futures-channel/build.rs @@ -1,9 +1,3 @@ -#![warn(rust_2018_idioms, single_use_lifetimes)] - -use std::env; - -include!("no_atomic_cas.rs"); - // The rustc-cfg listed below are considered public API, but it is *unstable* // and outside of the normal semver guarantees: // @@ -13,10 +7,15 @@ include!("no_atomic_cas.rs"); // need to enable it manually when building for custom targets or using // non-cargo build systems that don't run the build script. // -// With the exceptions mentioned above, the rustc-cfg strings below are -// *not* public API. Please let us know by opening a GitHub issue if your build -// environment requires some way to enable these cfgs other than by executing -// our build script. +// With the exceptions mentioned above, the rustc-cfg emitted by the build +// script are *not* public API. + +#![warn(rust_2018_idioms, single_use_lifetimes)] + +use std::env; + +include!("no_atomic_cas.rs"); + fn main() { let target = match env::var("TARGET") { Ok(target) => target, diff --git a/futures-core/build.rs b/futures-core/build.rs index 6fd1ebdabf..05e0496d94 100644 --- a/futures-core/build.rs +++ b/futures-core/build.rs @@ -1,9 +1,3 @@ -#![warn(rust_2018_idioms, single_use_lifetimes)] - -use std::env; - -include!("no_atomic_cas.rs"); - // The rustc-cfg listed below are considered public API, but it is *unstable* // and outside of the normal semver guarantees: // @@ -13,10 +7,15 @@ include!("no_atomic_cas.rs"); // need to enable it manually when building for custom targets or using // non-cargo build systems that don't run the build script. // -// With the exceptions mentioned above, the rustc-cfg strings below are -// *not* public API. Please let us know by opening a GitHub issue if your build -// environment requires some way to enable these cfgs other than by executing -// our build script. +// With the exceptions mentioned above, the rustc-cfg emitted by the build +// script are *not* public API. + +#![warn(rust_2018_idioms, single_use_lifetimes)] + +use std::env; + +include!("no_atomic_cas.rs"); + fn main() { let target = match env::var("TARGET") { Ok(target) => target, diff --git a/futures-task/build.rs b/futures-task/build.rs index 6fd1ebdabf..05e0496d94 100644 --- a/futures-task/build.rs +++ b/futures-task/build.rs @@ -1,9 +1,3 @@ -#![warn(rust_2018_idioms, single_use_lifetimes)] - -use std::env; - -include!("no_atomic_cas.rs"); - // The rustc-cfg listed below are considered public API, but it is *unstable* // and outside of the normal semver guarantees: // @@ -13,10 +7,15 @@ include!("no_atomic_cas.rs"); // need to enable it manually when building for custom targets or using // non-cargo build systems that don't run the build script. // -// With the exceptions mentioned above, the rustc-cfg strings below are -// *not* public API. Please let us know by opening a GitHub issue if your build -// environment requires some way to enable these cfgs other than by executing -// our build script. +// With the exceptions mentioned above, the rustc-cfg emitted by the build +// script are *not* public API. + +#![warn(rust_2018_idioms, single_use_lifetimes)] + +use std::env; + +include!("no_atomic_cas.rs"); + fn main() { let target = match env::var("TARGET") { Ok(target) => target, diff --git a/futures-util/build.rs b/futures-util/build.rs index 6fd1ebdabf..05e0496d94 100644 --- a/futures-util/build.rs +++ b/futures-util/build.rs @@ -1,9 +1,3 @@ -#![warn(rust_2018_idioms, single_use_lifetimes)] - -use std::env; - -include!("no_atomic_cas.rs"); - // The rustc-cfg listed below are considered public API, but it is *unstable* // and outside of the normal semver guarantees: // @@ -13,10 +7,15 @@ include!("no_atomic_cas.rs"); // need to enable it manually when building for custom targets or using // non-cargo build systems that don't run the build script. // -// With the exceptions mentioned above, the rustc-cfg strings below are -// *not* public API. Please let us know by opening a GitHub issue if your build -// environment requires some way to enable these cfgs other than by executing -// our build script. +// With the exceptions mentioned above, the rustc-cfg emitted by the build +// script are *not* public API. + +#![warn(rust_2018_idioms, single_use_lifetimes)] + +use std::env; + +include!("no_atomic_cas.rs"); + fn main() { let target = match env::var("TARGET") { Ok(target) => target, From 2abcb302567adb12f3f206891e96a6ec7c0d7a21 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Sun, 6 Feb 2022 14:46:19 +0900 Subject: [PATCH 3/3] Automatically creates PR when no_atomic_cas.rs needs to be updated --- .github/workflows/ci.yml | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2d2b7b299b..c5d3c4d06c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -231,17 +231,40 @@ jobs: --features unstable --ignore-unknown-features # When this job failed, run ci/no_atomic_cas.sh and commit result changes. - # TODO(taiki-e): Ideally, this should be automated using a bot that creates - # PR when failed, but there is no bandwidth to implement it - # right now... codegen: runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write steps: - uses: actions/checkout@v2 - name: Install Rust run: rustup update nightly && rustup default nightly - run: ci/no_atomic_cas.sh - - run: git diff --exit-code + - run: git add -N . && git diff --exit-code + if: github.event_name != 'schedule' + - id: diff + run: | + git config user.name "Taiki Endo" + git config user.email "te316e89@gmail.com" + git add -N . + if ! git diff --exit-code; then + git add . + git commit -m "Update no_atomic_cas.rs" + echo "::set-output name=success::false" + fi + if: github.event_name == 'schedule' + - uses: peter-evans/create-pull-request@v3 + with: + title: Update no_atomic_cas.rs + body: | + Auto-generated by [create-pull-request][1] + [Please close and immediately reopen this pull request to run CI.][2] + + [1]: https://github.com/peter-evans/create-pull-request + [2]: https://github.com/peter-evans/create-pull-request/blob/HEAD/docs/concepts-guidelines.md#workarounds-to-trigger-further-workflow-runs + branch: update-no-atomic-cas-rs + if: github.event_name == 'schedule' && steps.diff.outputs.success == 'false' miri: name: cargo miri test