Skip to content

Commit

Permalink
ci: add github actions configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
pietroalbini committed Mar 24, 2020
1 parent 9d5c416 commit 9beb8f5
Show file tree
Hide file tree
Showing 17 changed files with 1,909 additions and 12 deletions.
781 changes: 781 additions & 0 deletions .github/workflows/ci.yml

Large diffs are not rendered by default.

56 changes: 55 additions & 1 deletion Cargo.lock
Expand Up @@ -443,7 +443,7 @@ dependencies = [
"textwrap",
"unicode-width",
"vec_map",
"yaml-rust",
"yaml-rust 0.3.5",
]

[[package]]
Expand Down Expand Up @@ -1026,6 +1026,14 @@ dependencies = [
"walkdir",
]

[[package]]
name = "expand-yaml-anchors"
version = "0.1.0"
dependencies = [
"yaml-merge-keys",
"yaml-rust 0.4.3",
]

[[package]]
name = "failure"
version = "0.1.5"
Expand Down Expand Up @@ -1830,6 +1838,12 @@ dependencies = [
name = "linkchecker"
version = "0.1.0"

[[package]]
name = "linked-hash-map"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83"

[[package]]
name = "lock_api"
version = "0.3.1"
Expand Down Expand Up @@ -4854,6 +4868,26 @@ dependencies = [
"unicode-width",
]

[[package]]
name = "thiserror"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9fb62ff737e573b1e677459bea6fd023cd5d6e868c3242d3cdf3ef2f0554824"
dependencies = [
"thiserror-impl",
]

[[package]]
name = "thiserror-impl"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24069c0ba08aab54289d6a25f5036d94afc61e1538bbc42ae5501df141c9027d"
dependencies = [
"proc-macro2 1.0.3",
"quote 1.0.2",
"syn 1.0.11",
]

[[package]]
name = "thread_local"
version = "0.3.6"
Expand Down Expand Up @@ -5536,8 +5570,28 @@ dependencies = [
"lzma-sys",
]

[[package]]
name = "yaml-merge-keys"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59893318ba3ad2b704498c7761214a10eaf42c5f838bce9fc0145bf2ba658cfa"
dependencies = [
"lazy_static 1.4.0",
"thiserror",
"yaml-rust 0.4.3",
]

[[package]]
name = "yaml-rust"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e66366e18dc58b46801afbf2ca7661a9f59cc8c5962c29892b6039b4f86fa992"

[[package]]
name = "yaml-rust"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "65923dd1784f44da1d2c3dbbc5e822045628c590ba72123e1c73d3c230c4434d"
dependencies = [
"linked-hash-map",
]
1 change: 1 addition & 0 deletions Cargo.toml
Expand Up @@ -24,6 +24,7 @@ members = [
"src/tools/miri",
"src/tools/rustdoc-themes",
"src/tools/unicode-table-generator",
"src/tools/expand-yaml-anchors",
]
exclude = [
"build",
Expand Down
5 changes: 5 additions & 0 deletions src/bootstrap/builder.rs
Expand Up @@ -21,6 +21,7 @@ use crate::doc;
use crate::flags::Subcommand;
use crate::install;
use crate::native;
use crate::run;
use crate::test;
use crate::tool;
use crate::util::{self, add_dylib_path, add_link_lib_path, exe, libdir};
Expand Down Expand Up @@ -313,6 +314,7 @@ pub enum Kind {
Dist,
Doc,
Install,
Run,
}

impl<'a> Builder<'a> {
Expand Down Expand Up @@ -353,6 +355,7 @@ impl<'a> Builder<'a> {
}
Kind::Test => describe!(
crate::toolstate::ToolStateCheck,
test::ExpandYamlAnchors,
test::Tidy,
test::Ui,
test::CompileFail,
Expand Down Expand Up @@ -454,6 +457,7 @@ impl<'a> Builder<'a> {
install::Src,
install::Rustc
),
Kind::Run => describe!(run::ExpandYamlAnchors,),
}
}

Expand Down Expand Up @@ -507,6 +511,7 @@ impl<'a> Builder<'a> {
Subcommand::Bench { ref paths, .. } => (Kind::Bench, &paths[..]),
Subcommand::Dist { ref paths } => (Kind::Dist, &paths[..]),
Subcommand::Install { ref paths } => (Kind::Install, &paths[..]),
Subcommand::Run { ref paths } => (Kind::Run, &paths[..]),
Subcommand::Format { .. } | Subcommand::Clean { .. } => panic!(),
};

Expand Down
24 changes: 24 additions & 0 deletions src/bootstrap/flags.rs
Expand Up @@ -86,6 +86,9 @@ pub enum Subcommand {
Install {
paths: Vec<PathBuf>,
},
Run {
paths: Vec<PathBuf>,
},
}

impl Default for Subcommand {
Expand Down Expand Up @@ -113,6 +116,7 @@ Subcommands:
clean Clean out build directories
dist Build distribution artifacts
install Install distribution artifacts
run Run tools contained in this repository
To learn more about a subcommand, run `./x.py <subcommand> -h`",
);
Expand Down Expand Up @@ -188,6 +192,7 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`",
|| (s == "clean")
|| (s == "dist")
|| (s == "install")
|| (s == "run")
});
let subcommand = match subcommand {
Some(s) => s,
Expand Down Expand Up @@ -400,6 +405,18 @@ Arguments:
./x.py doc --stage 1",
);
}
"run" => {
subcommand_help.push_str(
"\n
Arguments:
This subcommand accepts a number of paths to tools to build and run. For
example:
./x.py run src/tool/expand-yaml-anchors
At least a tool needs to be called.",
);
}
_ => {}
};
// Get any optional paths which occur after the subcommand
Expand Down Expand Up @@ -468,6 +485,13 @@ Arguments:
"fmt" => Subcommand::Format { check: matches.opt_present("check") },
"dist" => Subcommand::Dist { paths },
"install" => Subcommand::Install { paths },
"run" => {
if paths.is_empty() {
println!("\nrun requires at least a path!\n");
usage(1, &opts, &subcommand_help, &extra_help);
}
Subcommand::Run { paths }
}
_ => {
usage(1, &opts, &subcommand_help, &extra_help);
}
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/lib.rs
Expand Up @@ -140,6 +140,7 @@ mod format;
mod install;
mod metadata;
mod native;
mod run;
mod sanity;
mod test;
mod tool;
Expand Down
45 changes: 45 additions & 0 deletions src/bootstrap/run.rs
@@ -0,0 +1,45 @@
use crate::builder::{Builder, RunConfig, ShouldRun, Step};
use crate::tool::Tool;
use std::process::Command;

#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct ExpandYamlAnchors;

impl Step for ExpandYamlAnchors {
type Output = ();
const DEFAULT: bool = true;
const ONLY_HOSTS: bool = true;

/// Runs the `expand-yaml_anchors` tool.
///
/// This tool in `src/tools` read the CI configuration files written in YAML and expands the
/// anchors in them, since GitHub Actions doesn't support them.
fn run(self, builder: &Builder<'_>) {
builder.info("Expanding YAML anchors in the GitHub Actions configuration");
try_run(
builder,
&mut builder.tool_cmd(Tool::ExpandYamlAnchors).arg("generate").arg(&builder.src),
);
}

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.path("src/tools/expand-yaml-anchors")
}

fn make_run(run: RunConfig<'_>) {
run.builder.ensure(ExpandYamlAnchors);
}
}

fn try_run(builder: &Builder<'_>, cmd: &mut Command) -> bool {
if !builder.fail_fast {
if !builder.try_run(cmd) {
let mut failures = builder.delayed_failures.borrow_mut();
failures.push(format!("{:?}", cmd));
return false;
}
} else {
builder.run(cmd);
}
true
}
29 changes: 29 additions & 0 deletions src/bootstrap/test.rs
Expand Up @@ -750,6 +750,35 @@ impl Step for Tidy {
}
}

#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct ExpandYamlAnchors;

impl Step for ExpandYamlAnchors {
type Output = ();
const ONLY_HOSTS: bool = true;

/// Ensure the `generate-ci-config` tool was run locally.
///
/// The tool in `src/tools` reads the CI definition in `src/ci/builders.yml` and generates the
/// appropriate configuration for all our CI providers. This step ensures the tool was called
/// by the user before committing CI changes.
fn run(self, builder: &Builder<'_>) {
builder.info("Ensuring the YAML anchors in the GitHub Actions config were expanded");
try_run(
builder,
&mut builder.tool_cmd(Tool::ExpandYamlAnchors).arg("check").arg(&builder.src),
);
}

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.path("src/tools/expand-yaml-anchors")
}

fn make_run(run: RunConfig<'_>) {
run.builder.ensure(ExpandYamlAnchors);
}
}

fn testdir(builder: &Builder<'_>, host: Interned<String>) -> PathBuf {
builder.out.join(host).join("test")
}
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/tool.rs
Expand Up @@ -378,6 +378,7 @@ bootstrap_tool!(
RemoteTestClient, "src/tools/remote-test-client", "remote-test-client";
RustInstaller, "src/tools/rust-installer", "fabricate", is_external_tool = true;
RustdocTheme, "src/tools/rustdoc-themes", "rustdoc-themes";
ExpandYamlAnchors, "src/tools/expand-yaml-anchors", "expand-yaml-anchors";
);

#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
Expand Down
3 changes: 2 additions & 1 deletion src/ci/docker/mingw-check/Dockerfile
Expand Up @@ -22,7 +22,8 @@ RUN sh /scripts/sccache.sh
COPY mingw-check/validate-toolstate.sh /scripts/

ENV RUN_CHECK_WITH_PARALLEL_QUERIES 1
ENV SCRIPT python2.7 ../x.py check --target=i686-pc-windows-gnu --host=i686-pc-windows-gnu && \
ENV SCRIPT python2.7 ../x.py test src/tools/expand-yaml-anchors && \
python2.7 ../x.py check --target=i686-pc-windows-gnu --host=i686-pc-windows-gnu && \
python2.7 ../x.py build --stage 0 src/tools/build-manifest && \
python2.7 ../x.py test --stage 0 src/tools/compiletest && \
python2.7 ../x.py test src/tools/tidy && \
Expand Down
16 changes: 16 additions & 0 deletions src/ci/exec-with-shell.py
@@ -0,0 +1,16 @@
#!/usr/bin/env python
# A simple wrapper that forwards the arguments to bash, unless the
# CI_OVERRIDE_SHELL environment variable is present: in that case the content
# of that environment variable is used as the shell path.

import os
import sys
import subprocess

try:
shell = os.environ["CI_OVERRIDE_SHELL"]
except KeyError:
shell = "bash"

res = subprocess.call([shell] + sys.argv[1:])
sys.exit(res)

0 comments on commit 9beb8f5

Please sign in to comment.