Skip to content
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

Automatically creates PR when no_atomic_cas.rs needs to be updated #2562

Merged
merged 3 commits into from Feb 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 27 additions & 4 deletions .github/workflows/ci.yml
Expand Up @@ -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
Expand Down
35 changes: 19 additions & 16 deletions 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}" <<EOF
// This file is @generated by $(basename "$0").
// It is not intended for manual editing.

const NO_ATOMIC_CAS: &[&str] = &[
EOF
for target in "${no_atomic_cas[@]}"; do
echo " \"${target}\"," >>"${file}"
done
cat >>"${file}" <<EOF
];
EOF
21 changes: 10 additions & 11 deletions 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:
//
Expand All @@ -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,
Expand All @@ -34,7 +33,7 @@ fn main() {
// `cfg(target_has_atomic = "ptr")` as true when the build script doesn't
// run. This is needed for compatibility with non-cargo build systems that
// don't run the build script.
if NO_ATOMIC_CAS_TARGETS.contains(&&*target) {
if NO_ATOMIC_CAS.contains(&&*target) {
println!("cargo:rustc-cfg=futures_no_atomic_cas");
}

Expand Down
21 changes: 10 additions & 11 deletions 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:
//
Expand All @@ -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,
Expand All @@ -34,7 +33,7 @@ fn main() {
// `cfg(target_has_atomic = "ptr")` as true when the build script doesn't
// run. This is needed for compatibility with non-cargo build systems that
// don't run the build script.
if NO_ATOMIC_CAS_TARGETS.contains(&&*target) {
if NO_ATOMIC_CAS.contains(&&*target) {
println!("cargo:rustc-cfg=futures_no_atomic_cas");
}

Expand Down
21 changes: 10 additions & 11 deletions 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:
//
Expand All @@ -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,
Expand All @@ -34,7 +33,7 @@ fn main() {
// `cfg(target_has_atomic = "ptr")` as true when the build script doesn't
// run. This is needed for compatibility with non-cargo build systems that
// don't run the build script.
if NO_ATOMIC_CAS_TARGETS.contains(&&*target) {
if NO_ATOMIC_CAS.contains(&&*target) {
println!("cargo:rustc-cfg=futures_no_atomic_cas");
}

Expand Down
21 changes: 10 additions & 11 deletions 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:
//
Expand All @@ -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,
Expand All @@ -34,7 +33,7 @@ fn main() {
// `cfg(target_has_atomic = "ptr")` as true when the build script doesn't
// run. This is needed for compatibility with non-cargo build systems that
// don't run the build script.
if NO_ATOMIC_CAS_TARGETS.contains(&&*target) {
if NO_ATOMIC_CAS.contains(&&*target) {
println!("cargo:rustc-cfg=futures_no_atomic_cas");
}

Expand Down
2 changes: 1 addition & 1 deletion no_atomic_cas.rs
@@ -1,7 +1,7 @@
// This file is @generated by no_atomic_cas.sh.
// It is not intended for manual editing.

const NO_ATOMIC_CAS_TARGETS: &[&str] = &[
const NO_ATOMIC_CAS: &[&str] = &[
"avr-unknown-gnu-atmega328",
"bpfeb-unknown-none",
"bpfel-unknown-none",
Expand Down