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 tweaks #885

Merged
merged 9 commits into from
Apr 18, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 61 additions & 20 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,77 @@ name: GlareDB CI

on: [push, workflow_dispatch]

# Jobs:
# build -> Builds binaries. This will build and cache deps as well.
# test -> Runs tests, using cache from 'build'.
# integration -> Runs integration tests, using cache from 'build'.
#
# Cachix is used for caching.

jobs:
pre_test:
continue-on-error: true
runs-on: ubuntu-latest
build:
name: Build
runs-on: ubuntu-latest-8-cores
concurrency:
group: build-ci-${{ github.ref }}
cancel-in-progress: true
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install nix
uses: cachix/install-nix-action@v20
with:
extra_nix_config: |
access-tokens = github=${{ github.token }}

- name: Configure Cachix
uses: cachix/cachix-action@v12
continue-on-error: true
with:
name: glaredb-ci
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'

- name: Build
run: |
nix build .#glaredb-bin -L
nix build .#slt-runner-bin -L
nix build .#pgprototest-bin -L

test:
needs: build
name: Tests
runs-on: ubuntu-latest-8-cores
concurrency:
group: ci-${{ github.ref }}
group: test-ci-${{ github.ref }}
cancel-in-progress: true
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}

steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v4
- name: Checkout
uses: actions/checkout@v3

- name: Install nix
uses: cachix/install-nix-action@v20
with:
extra_nix_config: |
access-tokens = github=${{ github.token }}

- name: Configure Cachix
uses: cachix/cachix-action@v12
continue-on-error: true
with:
concurrent_skipping: 'same_content_newer'
skip_after_successful_duplicate: 'true'
paths_ignore: '["**/README.md", "**/docs/**"]'
cancel_others: 'true'
name: glaredb-ci
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'

- name: Run Checks
run: nix flake check -L

test:
needs: pre_test
if: ${{ needs.pre_test.outputs.should_skip != 'true' }}
name: CI
integration:
needs: build
name: Integration tests
runs-on: ubuntu-latest-8-cores
concurrency:
group: ci-${{ github.ref }}
group: integ-ci-${{ github.ref }}
cancel-in-progress: true

env:
Expand All @@ -54,9 +98,6 @@ jobs:
name: glaredb-ci
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'

- name: Run Checks
run: nix flake check -L

- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v1
with:
Expand Down
6 changes: 0 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions crates/buildenv/Cargo.toml

This file was deleted.

21 changes: 0 additions & 21 deletions crates/buildenv/build.rs

This file was deleted.

9 changes: 0 additions & 9 deletions crates/buildenv/src/lib.rs

This file was deleted.

1 change: 0 additions & 1 deletion crates/glaredb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ path = "src/bin/main.rs"

[dependencies]
logutil = {path = "../logutil"}
buildenv = {path = "../buildenv"}
sqlexec = {path = "../sqlexec"}
telemetry = {path = "../telemetry"}
pgsrv = {path = "../pgsrv"}
Expand Down
3 changes: 1 addition & 2 deletions crates/glaredb/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ fn main() -> Result<()> {
let cli = Cli::parse();
logutil::init(cli.verbose, cli.json_logging);

let version = buildenv::git_tag();
info!(%version, "starting...");
info!("starting...");

match cli.command {
Commands::Server {
Expand Down
1 change: 0 additions & 1 deletion crates/sqlexec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ edition = {workspace = true}
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
buildenv = {path = "../buildenv"}
pgrepr = {path = "../pgrepr"}
metastore = {path = "../metastore"}
telemetry = {path = "../telemetry"}
Expand Down
15 changes: 0 additions & 15 deletions crates/sqlexec/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ use std::sync::Arc;
/// Additional built-in scalar functions.
#[derive(Debug, Copy, Clone)]
pub enum BuiltinScalarFunction {
/// 'version' -> String
/// Get the version of this db instance.
Version,

/// 'connection_id' -> String
/// Get the connection id that this session was started with.
ConnectionId,
Expand All @@ -33,7 +29,6 @@ impl BuiltinScalarFunction {
// TODO: We can probably move to some fancier function resolution in the
// future.
Some(match name {
"version" => BuiltinScalarFunction::Version,
"connection_id" => BuiltinScalarFunction::ConnectionId,

// Postgres system functions.
Expand Down Expand Up @@ -67,7 +62,6 @@ impl BuiltinScalarFunction {
/// Get the name of the built-in function.
fn name(&self) -> &'static str {
match self {
BuiltinScalarFunction::Version => "version",
BuiltinScalarFunction::ConnectionId => "connection_id",
BuiltinScalarFunction::CurrentSchemas => "current_schemas",
}
Expand All @@ -76,9 +70,6 @@ impl BuiltinScalarFunction {
/// Get the signature for a function.
fn signature(&self) -> Signature {
match self {
BuiltinScalarFunction::Version => {
Signature::new(TypeSignature::Exact(Vec::new()), Volatility::Immutable)
}
BuiltinScalarFunction::ConnectionId => {
Signature::new(TypeSignature::Exact(Vec::new()), Volatility::Immutable)
}
Expand All @@ -95,7 +86,6 @@ impl BuiltinScalarFunction {
/// Get the return type for a function.
fn return_type(&self) -> ReturnTypeFunction {
match self {
BuiltinScalarFunction::Version => Arc::new(|_| Ok(Arc::new(DataType::Utf8))),
BuiltinScalarFunction::CurrentSchemas => Arc::new(|_| {
Ok(Arc::new(DataType::List(Arc::new(Field::new(
"",
Expand All @@ -113,11 +103,6 @@ impl BuiltinScalarFunction {
/// the session (e.g. retrieving configuration values).
fn impl_function(&self, sess: &SessionContext) -> ScalarFunctionImplementation {
match self {
BuiltinScalarFunction::Version => Arc::new(|_| {
Ok(ColumnarValue::Scalar(ScalarValue::Utf8(Some(
buildenv::git_tag().to_string(),
))))
}),
BuiltinScalarFunction::CurrentSchemas => {
let schemas: Vec<_> = sess
.get_session_vars()
Expand Down
14 changes: 0 additions & 14 deletions crates/sqlexec/src/vars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,6 @@ lazy_static! {
};
}

// GlareDB specific.
const GLAREDB_BUILD_VERSION: ServerVar<str> = ServerVar {
name: "glaredb_build_version",
value: buildenv::git_tag(),
};

// GlareDB specific.
const ENABLE_DEBUG_DATASOURCES: ServerVar<bool> = ServerVar {
name: "enable_debug_datasources",
Expand Down Expand Up @@ -91,7 +85,6 @@ pub struct SessionVars {
pub datestyle: SessionVar<str>,
pub transaction_isolation: ServerVar<str>,
pub search_path: SessionVar<[String]>,
pub glaredb_build_version: ServerVar<str>,
pub enable_debug_datasources: SessionVar<bool>,
pub force_catalog_refresh: SessionVar<bool>,
}
Expand Down Expand Up @@ -128,8 +121,6 @@ impl SessionVars {
Ok(&self.transaction_isolation)
} else if name.eq_ignore_ascii_case(SEARCH_PATH.name) {
Ok(&self.search_path)
} else if name.eq_ignore_ascii_case(GLAREDB_BUILD_VERSION.name) {
Ok(&self.glaredb_build_version)
} else if name.eq_ignore_ascii_case(ENABLE_DEBUG_DATASOURCES.name) {
Ok(&self.enable_debug_datasources)
} else if name.eq_ignore_ascii_case(FORCE_CATALOG_REFRESH.name) {
Expand Down Expand Up @@ -159,10 +150,6 @@ impl SessionVars {
Err(ExecError::VariableReadonly(SERVER_VERSION.name.to_string()))
} else if name.eq_ignore_ascii_case(SEARCH_PATH.name) {
self.search_path.set(val)
} else if name.eq_ignore_ascii_case(GLAREDB_BUILD_VERSION.name) {
Err(ExecError::VariableReadonly(
GLAREDB_BUILD_VERSION.name.to_string(),
))
} else if name.eq_ignore_ascii_case(ENABLE_DEBUG_DATASOURCES.name) {
self.enable_debug_datasources.set(val)
} else if name.eq_ignore_ascii_case(FORCE_CATALOG_REFRESH.name) {
Expand All @@ -185,7 +172,6 @@ impl Default for SessionVars {
datestyle: SessionVar::new(&DATESTYLE),
transaction_isolation: TRANSACTION_ISOLATION,
search_path: SessionVar::new(&SEARCH_PATH),
glaredb_build_version: GLAREDB_BUILD_VERSION,
enable_debug_datasources: SessionVar::new(&ENABLE_DEBUG_DATASOURCES),
force_catalog_refresh: SessionVar::new(&FORCE_CATALOG_REFRESH),
}
Expand Down
38 changes: 23 additions & 15 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,17 @@
];

# Configure crane using the pinned toolchain.
craneLib = crane.lib.${system}.overrideToolchain fenixToolchain;
craneLibFenix = crane.lib.${system}.overrideToolchain fenixToolchain;

craneLib = (craneLibFenix).overrideScope' (final: prev: {
# We override the behavior of `mkCargoDerivation` by adding a wrapper which
# will set a default value of `CARGO_PROFILE` when not set by the caller.
# This change will automatically be propagated to any other functions built
# on top of it (like `buildPackage`, `cargoBuild`, etc.)
mkCargoDerivation = args: prev.mkCargoDerivation ({
CARGO_PROFILE = ""; # Unset profile (crane defaults to release)
} // args);
});

# Run-time dependencies.
buildInputs = [
Expand Down Expand Up @@ -79,18 +89,13 @@
# Filter source to to only include the files we care about for
# building.
src = lib.cleanSourceWith {
src = ./.;
src = craneLib.path ./.;
filter = filterSources;
};

# The `prost` crate uses `protoc` for parsing protobuf files. Ensure it
# can find the one we're providing with nix.
PROTOC = "${pkgs.protobuf}/bin/protoc";

# Used during build time to inject the git revision into the binary.
#
# See the `buildenv` crate.
GIT_TAG_OVERRIDE = self.rev or "dirty";
};

# Derivation for generating and including SSL certs.
Expand Down Expand Up @@ -151,34 +156,37 @@
++ buildInputs
++ nativeBuildInputs;

cargoArtifacts = craneLib.buildDepsOnly ({
pname = "glaredb-artifacts";
doCheck = false;
} // common-build-args);

# GlareDB binary.
#
# This is also used for cargo artifacts for downstream targets (since
# this pretty much builds everything).
glaredb-bin = craneLib.buildPackage (common-build-args // {
inherit cargoArtifacts;
pname = "glaredb";
cargoExtraArgs = "--bin glaredb";
doCheck = false;
doInstallCargoArtifacts = true;
});

# Release binary.
glaredb-bin-release = craneLib.buildPackage (common-build-args // {
CARGO_PROFILE = "release";
pname = "glaredb-release";
cargoExtraArgs = "--bin glaredb";
doCheck = false;
});


# GlareDB image (with release).
glaredb-image = mkContainer {
name = "glaredb";
contents = [
pkgs.openssh
glaredb-bin
glaredb-bin-release
# Generated certs used for SSL connections in pgsrv. GlareDB
# proper does not currently use certs.
generated-certs
];
config.Cmd = ["${glaredb-bin}/bin/glaredb"];
config.Cmd = ["${glaredb-bin-release}/bin/glaredb"];
};

# SLT runner binary.
Expand Down
6 changes: 0 additions & 6 deletions testdata/sqllogictests/functions/version.slt

This file was deleted.