-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8ea51d7
commit c436417
Showing
2 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
version: 2 | ||
jobs: | ||
test: | ||
docker: | ||
- image: node:8 | ||
|
||
working_directory: ~/repo | ||
|
||
steps: | ||
- checkout | ||
|
||
# Download and cache dependencies | ||
- restore_cache: | ||
keys: | ||
- v1-dependencies-{{ checksum "package.json" }} | ||
# fallback to using the latest cache if no exact match is found | ||
- v1-dependencies- | ||
|
||
- run: yarn install | ||
|
||
- save_cache: | ||
paths: | ||
- node_modules | ||
key: v1-dependencies-{{ checksum "package.json" }} | ||
|
||
- run: yarn test | ||
|
||
check_version: | ||
docker: | ||
- image: node:8 | ||
|
||
working_directory: ~/repo | ||
|
||
environment: | ||
- PRODUCTION_BRANCH: master | ||
|
||
steps: | ||
- checkout | ||
|
||
- run: | ||
name: Check version | ||
command: | | ||
pr_number=$( | ||
echo $CIRCLE_PULL_REQUEST | sed -E "s/.+\/([0-9]+)$/\1/g" | ||
) | ||
if [[ -n ${pr_number} ]]; then | ||
curl -L "https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64" -o jq | ||
chmod +x jq | ||
url="https://api.github.com/repos/developmentseed/collecticons-processor/pulls/$pr_number?access_token=$GITHUB_TOKEN" | ||
target_branch=$( | ||
curl "$url" | ./jq '.base.ref' | tr -d '"' | ||
) | ||
if [ "${target_branch}" == "${PRODUCTION_BRANCH}" ]; then | ||
package_version=$( | ||
cat package.json | ./jq '.version' | ||
) | ||
echo $package_version | ||
git tag --list | egrep -c '^v${package_version}$' | ||
version_exists=$( | ||
git tag --list | egrep -c '^v${package_version}$' | ||
) | ||
# echo $version_exists | ||
# if [[ $version_exists -eq 0 ]]; then | ||
# echo "Version ($package_version) is ok"; | ||
# else | ||
# echo "Version ($package_version) already exists"; | ||
# exit 1 | ||
# fi | ||
else | ||
echo "Not targetting ${PRODUCTION_BRANCH} branch" | ||
fi | ||
fi | ||
workflows: | ||
version: 2 | ||
only_test: | ||
jobs: | ||
- test | ||
- check_version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package_version=$( | ||
cat package.json | jq '.version' | ||
) | ||
echo $package_version | ||
|
||
version_exists=$( | ||
git tag --list | egrep -c '^v${package_version}$' | ||
) | ||
echo $version_exists |