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

chore(ci): run tests with an older glibc #800

Merged
merged 25 commits into from
Sep 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
28f53a7
chore(ci): test docker images
EverlastingBugstopper Sep 13, 2021
3529b65
try without dind
EverlastingBugstopper Sep 13, 2021
47540fb
put checkout back where it was
EverlastingBugstopper Sep 13, 2021
7b71de5
dont duplicate executor names
EverlastingBugstopper Sep 13, 2021
8c17980
install build-essential
EverlastingBugstopper Sep 13, 2021
e0f024b
install pkg-config
EverlastingBugstopper Sep 13, 2021
3c7d74f
chore(ci): test rover's glibc version
EverlastingBugstopper Sep 13, 2021
2683f05
wip: add glibc checker to tests
EverlastingBugstopper Sep 13, 2021
b056b2e
wip: only check glibc in CI
EverlastingBugstopper Sep 13, 2021
f6af502
wip: add xenial image to matrix
EverlastingBugstopper Sep 13, 2021
2508d9d
try centos image
EverlastingBugstopper Sep 14, 2021
66ea7a6
try centos:7
EverlastingBugstopper Sep 14, 2021
43ee88f
chore(ci): use yum for centos packages
EverlastingBugstopper Sep 14, 2021
69fe1e4
chore(ci): add -y to yum commands
EverlastingBugstopper Sep 14, 2021
815ce43
chore(ci): fix up bad find and replace
EverlastingBugstopper Sep 14, 2021
19ae9b9
chore(ci): install cmake for centos
EverlastingBugstopper Sep 14, 2021
afa74a5
chore(ci): install gcc instead of cmake
EverlastingBugstopper Sep 14, 2021
950dbb9
chore(ci): install openssl on centos
EverlastingBugstopper Sep 14, 2021
85fd242
chore(ci): groupinstall dev tools centos
EverlastingBugstopper Sep 14, 2021
60c4981
chore(ci): use ubuntu for lint
EverlastingBugstopper Sep 14, 2021
5d2e445
chore(ci): persist target directory for integration tests
EverlastingBugstopper Sep 14, 2021
391d042
chore(ci): persist correct directory
EverlastingBugstopper Sep 14, 2021
4e2ebed
chore(ci): dont persist directory, it's slow
EverlastingBugstopper Sep 14, 2021
eedc678
chore(ci): run unit tests and integration tests on ubuntu
EverlastingBugstopper Sep 14, 2021
6f09ffe
chore(ci): run e2e tests in the same job
EverlastingBugstopper Sep 14, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 46 additions & 26 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ workflows:
name: Lint (<< matrix.rust_channel >> rust on << matrix.platform >>)
matrix:
parameters:
platform: [ubuntu_gnu_docker]
platform: [ubuntu]
rust_channel: [stable]
command: [lint]
test:
Expand All @@ -23,19 +23,17 @@ workflows:
name: Cargo tests (<< matrix.rust_channel >> rust on << matrix.platform >>)
matrix:
parameters:
platform: [ubuntu_gnu_docker, ubuntu_musl, macos, windows]
platform: [centos, musl, macos, windows]
rust_channel: [stable]
command: [unit-test]

- xtask:
name: Supergraph demo tests (<< matrix.rust_channel >> rust on << matrix.platform >>)
name: Cargo tests and supergraph demo (<< matrix.rust_channel >> rust on << matrix.platform >>)
matrix:
parameters:
platform: [ubuntu_gnu_vm]
platform: [ubuntu]
rust_channel: [stable]
command: [integration-test]
requires:
- Cargo tests (<< matrix.rust_channel >> rust on ubuntu_gnu_docker)
command: [test]

jobs:
xtask:
Expand All @@ -48,35 +46,28 @@ jobs:
type: executor
command:
type: enum
enum: ["lint", "unit-test", "integration-test"]
enum: ["lint", "unit-test", "integration-test", "test", "dist"]
executor: << parameters.platform >>
steps:
- checkout
- install_system_deps:
platform: << parameters.platform >>
rust_channel: << parameters.rust_channel >>
- exec_xtask:
command: << parameters.command >>
platform: << parameters.platform >>
command: << parameters.command >>

# The machines we use to run our workflows on
executors:
ubuntu_gnu_docker: &ubuntu_gnu_docker_executor
centos: &centos_executor
docker:
- image: cimg/base:stable
- image: centos:7
resource_class: xlarge
environment:
XTASK_TARGET: "x86_64-unknown-linux-gnu"
CHECK_GLIBC: "true"

# This is only used to run supergraph-demo since you can't run Docker from Docker
ubuntu_gnu_vm: &ubuntu_gnu_vm_executor
machine:
image: ubuntu-1604:202104-01
resource_class: xlarge
environment:
XTASK_TARGET: "x86_64-unknown-linux-gnu"

ubuntu_musl: &ubuntu_musl_executor
musl: &musl_executor
docker:
- image: cimg/base:stable
resource_class: xlarge
Expand All @@ -98,6 +89,14 @@ executors:
environment:
XTASK_TARGET: "x86_64-pc-windows-msvc"

# This is only used to run supergraph-demo since you can't run Docker from Docker
ubuntu: &ubuntu_executor
machine:
image: ubuntu-2004:202010-01
resource_class: xlarge
environment:
XTASK_TARGET: "x86_64-unknown-linux-gnu"

# reusable command snippets can be referred to in any `steps` object
commands:
install_system_deps:
Expand All @@ -111,26 +110,47 @@ commands:
- when:
condition:
or:
- equal: [ *ubuntu_gnu_docker_executor, << parameters.platform >> ]
- equal: [ *ubuntu_gnu_vm_executor, << parameters.platform >> ]
- equal: [ *ubuntu_musl_executor, << parameters.platform >> ]
- equal: [ *ubuntu_executor, << parameters.platform >> ]
- equal: [ *musl_executor, << parameters.platform >> ]
steps:
- run:
name: Update apt repositories
command: sudo apt-get update
- run:
name: Check glibc version
command: ldd --version
- run:
name: Install OpenSSL
command: sudo apt-get install -y libssl-dev

- when:
condition:
equal: [ *ubuntu_musl_executor, << parameters.platform >> ]
equal: [ *centos_executor, << parameters.platform >> ]
steps:
- run:
name: Update and upgrade yum packages
command: yum -y update && yum -y upgrade
- run:
name: Install development tools
command: yum groupinstall -y "Development Tools"
- run:
name: Install gcc and OpenSSL
command: yum -y install gcc openssl-devel
- run:
name: Check glibc version
command: ldd --version

- when:
condition:
equal: [ *musl_executor, << parameters.platform >> ]
steps:
- run:
name: Install musl-tools
command: sudo apt-get install -y musl-tools
- when:
condition:
equal: [ *ubuntu_gnu_docker_executor, << parameters.platform >> ]
or:
- equal: [ *ubuntu_executor, << parameters.platform >> ]
steps:
- node/install:
node-version: "14.17.1"
Expand Down Expand Up @@ -195,7 +215,7 @@ commands:
parameters:
command:
type: enum
enum: [lint, integration-test, unit-test]
enum: [lint, integration-test, unit-test, "test", "dist"]
platform:
type: executor
steps:
Expand Down
67 changes: 67 additions & 0 deletions check_glibc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/bash

# This scripts checks if Rover's compiled executable only asks for
# supported versions of glibc

# source: https://gist.github.com/fasterthanlime/17e002a8f5e0f189861c

# usage: ./check_glibc.sh ./target/debug/rover

MAX_VER=2.18

SCRIPTPATH=$( cd $(dirname $0) ; pwd -P )
BINARY=$1

# Version comparison function in bash
vercomp () {
if [[ $1 == $2 ]]
then
return 0
fi
local IFS=.
local i ver1=($1) ver2=($2)
# fill empty fields in ver1 with zeros
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
do
ver1[i]=0
done
for ((i=0; i<${#ver1[@]}; i++))
do
if [[ -z ${ver2[i]} ]]
then
# fill empty fields in ver2 with zeros
ver2[i]=0
fi
if ((10#${ver1[i]} > 10#${ver2[i]}))
then
return 1
fi
if ((10#${ver1[i]} < 10#${ver2[i]}))
then
return 2
fi
done
return 0
}

IFS="
"
VERS=$(objdump -T $BINARY | grep GLIBC | sed 's/.*GLIBC_\([.0-9]*\).*/\1/g' | sort -u)

for VER in $VERS; do
vercomp $VER $MAX_VER
COMP=$?
if [[ $COMP -eq 1 ]]; then
echo "Error! ${BINARY} requests GLIBC ${VER}, which is higher than target ${MAX_VER}"
echo "Affected symbols:"
objdump -T $BINARY | grep GLIBC_${VER}
echo "Looking for symbols in libraries..."
for LIBRARY in $(ldd $BINARY | cut -d ' ' -f 3); do
echo $LIBRARY
objdump -T $LIBRARY | fgrep GLIBC_${VER}
done
exit 27
else
echo "Found version ${VER}"
fi
done
20 changes: 19 additions & 1 deletion xtask/src/commands/unit_test.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
use anyhow::Result;
use camino::Utf8PathBuf;
use structopt::StructOpt;

use crate::target::{Target, POSSIBLE_TARGETS};
use crate::tools::CargoRunner;
use crate::tools::{CargoRunner, Runner};
use crate::utils::PKG_PROJECT_ROOT;

use std::{env, str::FromStr};

#[derive(Debug, StructOpt)]
pub struct UnitTest {
Expand All @@ -15,6 +19,20 @@ impl UnitTest {
pub fn run(&self, verbose: bool) -> Result<()> {
let mut cargo_runner = CargoRunner::new(verbose)?;
cargo_runner.test(&self.target)?;

if let Target::GnuLinux = self.target {
if env::var_os("CHECK_GLIBC").is_some() {
let check_glibc_script = "./check_glibc.sh".to_string();
let runner = Runner {
verbose,
tool_name: check_glibc_script.clone(),
tool_exe: Utf8PathBuf::from_str(&check_glibc_script)?,
};
let bin_path = format!("./target/{}/debug/rover", &self.target);
runner.exec(&[&bin_path], &PKG_PROJECT_ROOT, None)?;
}
}

Ok(())
}
}