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

ci: split nix-build-test into nix-build nix-test and introduce circle ci contexts #1817

Merged
merged 4 commits into from
Apr 16, 2021
Merged
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
120 changes: 50 additions & 70 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,50 +68,6 @@ jobs:
command: |
test/create_test_db "postgres://circleci@localhost" postgrest_test stack test

# Run memory usage tests based on stack and docker.
stack-test-memory:
docker:
- image: cimg/base:2021.03
environment:
- PGHOST=localhost
- TERM=xterm
- image: circleci/postgres:12
environment:
- POSTGRES_USER=circleci
- POSTGRES_DB=circleci
- POSTGRES_HOST_AUTH_METHOD=trust
steps:
- checkout
- restore_cache:
keys:
- v1-stack-prof-dependencies-{{ checksum "postgrest.cabal" }}-{{ checksum "stack.yaml" }}
- run:
name: install stack & dependencies
command: |
curl -L https://github.com/commercialhaskell/stack/releases/download/v2.3.1/stack-2.3.1-linux-x86_64.tar.gz | tar zx -C /tmp
sudo mv /tmp/stack-2.3.1-linux-x86_64/stack /usr/bin
sudo apt-get update
sudo apt-get install -y libgmp-dev postgresql-client
stack setup
- run:
name: build dependencies with profiling enabled
command: |
stack build --profile -j1 --only-dependencies
- save_cache:
paths:
- "~/.stack"
- ".stack-work"
key: v1-stack-prof-dependencies-{{ checksum "postgrest.cabal" }}-{{ checksum "stack.yaml" }}
- run:
name: install with profiling enabled
command: |
stack install --profile -j1
- run:
name: run memory usage tests
command: |
export PATH="~/.local/bin:$PATH"
test/create_test_db "postgres://circleci@localhost" postgrest_test test/memory-tests.sh

# Publish a new release. This only runs when a release is tagged (see
# workflow below).
release:
Expand Down Expand Up @@ -156,8 +112,8 @@ jobs:
postgrest-release-dockerhubdescription
fi

# Build everything in default.nix, push to the Cachix binary cache and run tests
nix-build-test:
# Build everything in default.nix and push to the Cachix binary cache if running on main
nix-build:
machine: true
steps:
- checkout
Expand Down Expand Up @@ -191,51 +147,70 @@ jobs:
echo "Building all derivations (caching skipped for outside pull requests)..."
nix-build
fi

# Run tests
nix-test:
machine: true
steps:
- checkout
- run:
name: Install Nix
command: |
curl -L https://nixos.org/nix/install | sh
echo "source $HOME/.nix-profile/etc/profile.d/nix.sh" >> $BASH_ENV
- run:
name: Install and use the Cachix binary cache
command: |
nix-env -iA cachix -f https://cachix.org/api/v1/install
cachix use postgrest
- run:
name: Install testing scripts
command: nix-env -f default.nix -iA tests tests.memoryTests
- run:
name: Skip tests on build failure
name: Run coverage (io tests and spec tests against PostgreSQL 13)
command: postgrest-coverage
when: always
- run:
name: Skip tests on build or primary test failure
command: circleci-agent step halt
when: on_fail
- run:
name: Run the spec tests against PostgreSQL 9.5
command: postgrest-with-postgresql-9.5 postgrest-test-spec
name: Upload coverage to codecov
command: |
# Modified from:
# https://docs.codecov.io/docs/about-the-codecov-bash-uploader#validating-the-bash-script
curl -s https://codecov.io/bash > codecov;
VERSION=$(grep 'VERSION=\".*\"' codecov | cut -d'"' -f2);
shasum -a 512 -c <(curl -s https://raw.githubusercontent.com/codecov/codecov-bash/${VERSION}/SHA512SUM | grep codecov)
bash codecov -f coverage/codecov.json
- run:
name: Run the spec tests against PostgreSQL 12
command: postgrest-with-postgresql-12 postgrest-test-spec
when: always
- run:
name: Run the spec tests against PostgreSQL 9.6
command: postgrest-with-postgresql-9.6 postgrest-test-spec
name: Run the spec tests against PostgreSQL 11
command: postgrest-with-postgresql-11 postgrest-test-spec
when: always
- run:
name: Run the spec tests against PostgreSQL 10
command: postgrest-with-postgresql-10 postgrest-test-spec
when: always
- run:
name: Run the spec tests against PostgreSQL 11
command: postgrest-with-postgresql-11 postgrest-test-spec
name: Run the spec tests against PostgreSQL 9.6
command: postgrest-with-postgresql-9.6 postgrest-test-spec
when: always
- run:
name: Run the spec tests against PostgreSQL 12
command: postgrest-with-postgresql-12 postgrest-test-spec
name: Run the spec tests against PostgreSQL 9.5
command: postgrest-with-postgresql-9.5 postgrest-test-spec
when: always
- run:
name: Check the spec tests for idempotence against PostgreSQL 13
name: Check the spec tests for idempotence
command: postgrest-test-spec-idempotence
when: always
- run:
name: Run io tests
command: postgrest-test-io
when: always
- run:
name: Run memory tests
command: postgrest-test-memory
when: always
- run:
name: Run coverage
command: postgrest-coverage
- run:
name: Upload coverage to codecov
command: bash <(curl -s https://codecov.io/bash) -f coverage/codecov.json


workflows:
Expand All @@ -255,13 +230,15 @@ workflows:
only:
- /v[0-9]+(\.[0-9]+)*/
- nightly
- stack-test-memory:
- nix-build:
filters:
tags:
only:
- /v[0-9]+(\.[0-9]+)*/
- nightly
- nix-build-test:
context:
- cachix
- nix-test:
filters:
tags:
only:
Expand All @@ -271,12 +248,15 @@ workflows:
requires:
- style-check
- stack-test
- stack-test-memory
- nix-build-test
- nix-build
- nix-test
filters:
tags:
only:
- /v[0-9]+(\.[0-9]+)*/
- nightly
branches:
ignore: /.*/
context:
- docker
- github