Merge pull request #2303 from cgwalters/gh-actions

ci: Add a Github Action for Rust for tests/inst
This commit is contained in:
Colin Walters 2021-03-17 15:49:05 -04:00 committed by GitHub
commit 236a5ca9bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 13 deletions

27
.github/workflows/tests.yml vendored Normal file
View File

@ -0,0 +1,27 @@
---
name: Rust
on:
push:
branches: [master]
pull_request:
branches: [master]
env:
CARGO_TERM_COLOR: always
ACTIONS_LINTS_TOOLCHAIN: 1.50.0
jobs:
linting:
name: "Lints, pinned toolchain"
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env['ACTIONS_LINTS_TOOLCHAIN'] }}
default: true
components: rustfmt, clippy
- name: cargo fmt (check)
run: cd tests/inst && cargo fmt -- --check -l

View File

@ -108,21 +108,22 @@ impl RebootMark {
strategy: &InterruptStrategy,
) -> &mut BTreeMap<UpdateResult, u32> {
match strategy {
InterruptStrategy::Polite(t) => self
.polite
.entry(t.clone())
.or_insert_with(BTreeMap::new),
InterruptStrategy::Force(t) => self
.force
.entry(t.clone())
.or_insert_with(BTreeMap::new),
InterruptStrategy::Polite(t) => {
self.polite.entry(t.clone()).or_insert_with(BTreeMap::new)
}
InterruptStrategy::Force(t) => {
self.force.entry(t.clone()).or_insert_with(BTreeMap::new)
}
}
}
}
impl InterruptStrategy {
pub(crate) fn is_noop(&self) -> bool {
matches!(self, InterruptStrategy::Polite(PoliteInterruptStrategy::None))
matches!(
self,
InterruptStrategy::Polite(PoliteInterruptStrategy::None)
)
}
}
@ -598,9 +599,7 @@ fn transactionality() -> Result<()> {
upgrade_and_finalize().context("Firstrun upgrade failed")?;
let end = time::Instant::now();
let cycle_time = end.duration_since(start);
let tdata = TransactionalTestInfo {
cycle_time,
};
let tdata = TransactionalTestInfo { cycle_time };
let mut f = std::io::BufWriter::new(std::fs::File::create(&TDATAPATH)?);
serde_json::to_writer(&mut f, &tdata)?;
f.flush()?;

View File

@ -82,7 +82,7 @@ pub(crate) const TEST_HTTP_BASIC_AUTH: &str = "foouser:barpw";
fn validate_authz(value: &[u8]) -> Result<bool> {
let buf = std::str::from_utf8(&value)?;
if let Some(o) = buf.find("Basic ") {
let (_, buf) = buf.split_at(o + "Basic ".len());
let (_, buf) = buf.split_at(o + "Basic ".len());
let buf = base64::decode(buf).context("decoding")?;
let buf = std::str::from_utf8(&buf)?;
Ok(buf == TEST_HTTP_BASIC_AUTH)