这是indexloc提供的服务,不要输入任何密码
Skip to content
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
7 changes: 7 additions & 0 deletions .ciignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*.md
LICENSE
scripts/*
assets/*
.circleci/*
.ciignore
.gitignore
45 changes: 45 additions & 0 deletions .circleci/ciignore.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env bash

# Exit with error if diff with origin/master only contains files mentioned in
# .ciignore so that the build can be stopped.
#
# Adapted from:
# https://circleci.com/blog/circleci-hacks-automate-the-decision-to-skip-builds-using-a-git-hook/
# https://github.com/dollarshaveclub/harmless-changes/blob/master/index.sh

set -eo pipefail
ROOT="$(readlink -f ${BASH_SOURCE[0]%/*}/../)"

if [[ ! -a "$ROOT/.ciignore" ]]; then
exit # If .ciignore doesn't exists, just quit this script
fi

changes="$(git diff-tree --no-commit-id --name-only -r origin/master..HEAD)"

echo "CHANGES FROM ORIGIN/MASTER:"
echo $changes
echo

# Load the patterns we want to skip into an array
mapfile -t blacklist < "$ROOT/.ciignore"

for i in "${blacklist[@]}"
do
# Remove the current pattern from the list of changes
changes=( ${changes[@]/$i/} )

if [[ ${#changes[@]} -eq 0 ]]; then
# If we've exhausted the list of changes before we've finished going
# through patterns, that's okay, just quit the loop
break
fi
done

if [[ ${#changes[@]} -gt 0 ]]; then
# If there's still changes left, then we have stuff to build, leave the commit alone.
echo "Files that are not ignored present in commits, need to build, succeed the job"
exit
fi

echo "Only ignored files are present in commits, no need to build, fail the job"
exit 1
20 changes: 16 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ refs:

version: 2
jobs:
# check if this should be built or not, fails if
# changes only contains files in .ciignore
check_build_worthiness:
docker:
- image: hasura/graphql-engine-cli-builder:v0.2
working_directory: ~/graphql-engine
steps:
- checkout
- run:
name: check build worthiness
command: .circleci/ciignore.sh
# test build the server binary
test_and_build_server:
docker:
Expand All @@ -65,7 +76,6 @@ jobs:
name: test and build server binary
working_directory: ./server
command: |
# TODO: make test
DATABASE_URL="postgres://gql_test:@localhost:5432/gql_test" make ci-binary-and-test
make ci-image
make ci-save-image
Expand Down Expand Up @@ -156,7 +166,6 @@ jobs:
- ~/.npm
- ~/.cache
- *wait_for_postgres
# ignore console test for now
- run:
name: test console
command: .circleci/test-console.sh
Expand Down Expand Up @@ -193,15 +202,18 @@ workflows:
version: 2
build_and_test:
jobs:
- test_and_build_server: *filter_only_vtags
- check_build_worthiness: *filter_only_vtags
- test_and_build_server:
<<: *filter_only_vtags
requires:
- check_build_worthiness
- test_and_build_cli:
<<: *filter_only_vtags
requires:
- test_and_build_server
- test_and_build_console:
<<: *filter_only_vtags
requires:
- test_and_build_server
- test_and_build_cli
- deploy:
<<: *filter_only_vtags_dev_release_branches
Expand Down