Temporary directories are now created in $TMPDIR/postgrest/script-name-XXX. This allows recognizing the origin of a single temporary directory and uploading the whole $TMPDIR/postgrest folder as an artifact in CI.
277 lines
9.2 KiB
YAML
277 lines
9.2 KiB
YAML
version: 2
|
|
|
|
jobs:
|
|
# Make sure that there are no outstanding linting hints and that
|
|
# auto-formatting does not result in any changes.
|
|
style-check:
|
|
docker:
|
|
- image: nixos/nix:2.3
|
|
steps:
|
|
- checkout
|
|
- run:
|
|
name: Install linting and styling scripts
|
|
command: nix-env -f default.nix -iA style
|
|
- run:
|
|
name: Run linter
|
|
command: |
|
|
# Note: For checking this locally, use `nix-shell --run postgrest-lint`
|
|
postgrest-lint
|
|
- run:
|
|
name: Run style check
|
|
command: |
|
|
# 'Note: For checking this locally, use `nix-shell --run postgrest-style`
|
|
postgrest-style-check
|
|
|
|
# Run tests based on stack and docker against the oldest PostgreSQL version
|
|
# that we support.
|
|
stack-test:
|
|
docker:
|
|
- image: cimg/base:2021.03
|
|
environment:
|
|
- PGHOST=localhost
|
|
- image: circleci/postgres:9.5
|
|
environment:
|
|
- POSTGRES_USER=circleci
|
|
- POSTGRES_DB=circleci
|
|
- POSTGRES_HOST_AUTH_METHOD=trust
|
|
steps:
|
|
- checkout
|
|
- restore_cache:
|
|
keys:
|
|
- v1-stack-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
|
|
sudo apt-get install -y --only-upgrade binutils
|
|
stack setup
|
|
- run:
|
|
name: build src and tests dependencies
|
|
command: |
|
|
stack build --fast -j1 --only-dependencies
|
|
stack build --fast --test --no-run-tests --only-dependencies
|
|
- save_cache:
|
|
paths:
|
|
- "~/.stack"
|
|
- ".stack-work"
|
|
key: v1-stack-dependencies-{{ checksum "postgrest.cabal" }}-{{ checksum "stack.yaml" }}
|
|
- run:
|
|
name: build src and tests
|
|
command: |
|
|
stack build --fast -j1
|
|
stack build --fast --test --no-run-tests
|
|
- run:
|
|
name: run spec tests
|
|
command: |
|
|
test/create_test_db "postgres://circleci@localhost" postgrest_test stack test
|
|
- store_artifacts:
|
|
path: /tmp/postgrest
|
|
|
|
# Publish a new release. This only runs when a release is tagged (see
|
|
# workflow below).
|
|
release:
|
|
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: Change postgrest.cabal if nightly
|
|
command: |
|
|
if test "$CIRCLE_TAG" = "nightly"
|
|
then
|
|
cabal_nightly_version=$(git show -s --format='%cd' --date='format:%Y%m%d')
|
|
sed -i "s/^version:.*/version:$cabal_nightly_version/" postgrest.cabal
|
|
fi
|
|
- 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 release scripts
|
|
command: nix-env -f default.nix -iA release
|
|
- run:
|
|
name: Publish GitHub release
|
|
command: |
|
|
export GITHUB_USERNAME="$CIRCLE_PROJECT_USERNAME"
|
|
export GITHUB_REPONAME="$CIRCLE_PROJECT_REPONAME"
|
|
postgrest-release-github $CIRCLE_TAG
|
|
- run:
|
|
name: Publish Docker images
|
|
command: |
|
|
export DOCKER_REPO=postgrest
|
|
postgrest-release-docker-login
|
|
postgrest-release-dockerhub $CIRCLE_TAG
|
|
if test "$CIRCLE_TAG" != "nightly"
|
|
then
|
|
postgrest-release-dockerhub-description
|
|
fi
|
|
- store_artifacts:
|
|
path: /tmp/postgrest
|
|
|
|
# Build everything in default.nix and push to the Cachix binary cache if running on main
|
|
nix-build:
|
|
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: Change postgrest.cabal if nightly
|
|
command: |
|
|
if test "$CIRCLE_TAG" = "nightly"
|
|
then
|
|
cabal_nightly_version=$(git show -s --format='%cd' --date='format:%Y%m%d')
|
|
sed -i "s/^version:.*/version:$cabal_nightly_version/" postgrest.cabal
|
|
fi
|
|
- run:
|
|
name: Build all derivations from default.nix and push results to Cachix
|
|
command: |
|
|
# Only push to the cache when CircleCI makes the CACHIX_SIGNING_KEY
|
|
# available (e.g. not for pull requests).
|
|
if [ -n "${CACHIX_AUTH_TOKEN:-""}" ]; then
|
|
echo "Building and caching all derivations..."
|
|
cachix authtoken "$CACHIX_AUTH_TOKEN"
|
|
|
|
# Push new builds as we go
|
|
nix-build | cachix push postgrest
|
|
|
|
# Make sure that everything, including .drv files, is pushed
|
|
nix-env -f default.nix -iA devtools
|
|
postgrest-push-cachix
|
|
else
|
|
echo "Building all derivations (caching skipped for outside pull requests)..."
|
|
nix-build
|
|
fi
|
|
- store_artifacts:
|
|
path: /tmp/postgrest
|
|
|
|
# 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 memory withTools
|
|
- run:
|
|
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: 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 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 9.6
|
|
command: postgrest-with-postgresql-9.6 postgrest-test-spec
|
|
when: always
|
|
- run:
|
|
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
|
|
command: postgrest-test-spec-idempotence
|
|
when: always
|
|
- run:
|
|
name: Run memory tests
|
|
command: postgrest-test-memory
|
|
when: always
|
|
- store_artifacts:
|
|
path: /tmp/postgrest
|
|
|
|
workflows:
|
|
version: 2
|
|
build-test-release:
|
|
jobs:
|
|
- style-check:
|
|
# Make sure that this job also runs when releases are tagged.
|
|
filters:
|
|
tags:
|
|
only:
|
|
- /v[0-9]+(\.[0-9]+)*/
|
|
- nightly
|
|
- stack-test:
|
|
filters:
|
|
tags:
|
|
only:
|
|
- /v[0-9]+(\.[0-9]+)*/
|
|
- nightly
|
|
- nix-build:
|
|
filters:
|
|
tags:
|
|
only:
|
|
- /v[0-9]+(\.[0-9]+)*/
|
|
- nightly
|
|
context:
|
|
- cachix
|
|
- nix-test:
|
|
filters:
|
|
tags:
|
|
only:
|
|
- /v[0-9]+(\.[0-9]+)*/
|
|
- nightly
|
|
- release:
|
|
requires:
|
|
- style-check
|
|
- stack-test
|
|
- nix-build
|
|
- nix-test
|
|
filters:
|
|
tags:
|
|
only:
|
|
- /v[0-9]+(\.[0-9]+)*/
|
|
- nightly
|
|
branches:
|
|
ignore: /.*/
|
|
context:
|
|
- docker
|
|
- github
|