|
| 1 | +#!/usr/bin/env bash |
| 2 | +# |
| 3 | +# LanguageTool, a natural language style checker |
| 4 | +# Copyright (C) 2021 Stefan Viol (https://stevio.de) |
| 5 | +# |
| 6 | +# This library is free software; you can redistribute it and/or |
| 7 | +# modify it under the terms of the GNU Lesser General Public |
| 8 | +# License as published by the Free Software Foundation; either |
| 9 | +# version 2.1 of the License, or (at your option) any later version. |
| 10 | +# |
| 11 | +# This library is distributed in the hope that it will be useful, |
| 12 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | +# Lesser General Public License for more details. |
| 15 | +# |
| 16 | +# You should have received a copy of the GNU Lesser General Public |
| 17 | +# License along with this library; if not, write to the Free Software |
| 18 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 |
| 19 | +# USA |
| 20 | +# |
| 21 | + |
| 22 | +# Exit script if you try to use an uninitialized variable. |
| 23 | +set -o nounset |
| 24 | +# Exit script if a statement returns a non-true return value. |
| 25 | +set -o errexit |
| 26 | +# Use the error status of the first failure, rather than that of the last item in a pipeline. |
| 27 | +set -o pipefail |
| 28 | +# |
| 29 | +# LanguageTool, a natural language style checker |
| 30 | +# Copyright (C) 2021 Stefan Viol (https://stevio.de) |
| 31 | +# |
| 32 | +# This library is free software; you can redistribute it and/or |
| 33 | +# modify it under the terms of the GNU Lesser General Public |
| 34 | +# License as published by the Free Software Foundation; either |
| 35 | +# version 2.1 of the License, or (at your option) any later version. |
| 36 | +# |
| 37 | +# This library is distributed in the hope that it will be useful, |
| 38 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 39 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 40 | +# Lesser General Public License for more details. |
| 41 | +# |
| 42 | +# You should have received a copy of the GNU Lesser General Public |
| 43 | +# License along with this library; if not, write to the Free Software |
| 44 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 |
| 45 | +# USA |
| 46 | +# |
| 47 | + |
| 48 | +PROJECTS="" |
| 49 | +BRANCH="$(git rev-parse --abbrev-ref HEAD)" |
| 50 | +if [[ "$BRANCH" != "master" ]]; then |
| 51 | + echo "No premium tests for $BRANCH." |
| 52 | + exit 0 |
| 53 | +fi |
| 54 | +if grep -q -e "languagetool-core/.*" /home/circleci/git_diffs.txt; then |
| 55 | + PROJECTS="languagetool-core/" |
| 56 | +else |
| 57 | + if grep -q -e "languagetool-dev/.*" /home/circleci/git_diffs.txt; then PROJECTS="languagetool-dev/ $PROJECTS"; fi |
| 58 | + if grep -q -e "languagetool-language-modules/de/.*" /home/circleci/git_diffs.txt; then PROJECTS="languagetool-language-modules/de/ $PROJECTS"; fi |
| 59 | + if grep -q -e "languagetool-language-modules/en/.*" /home/circleci/git_diffs.txt; then PROJECTS="languagetool-language-modules/en/ $PROJECTS"; fi |
| 60 | + if grep -q -e "languagetool-language-modules/es/.*" /home/circleci/git_diffs.txt; then PROJECTS="languagetool-language-modules/es/ $PROJECTS"; fi |
| 61 | + if grep -q -e "languagetool-language-modules/fr/.*" /home/circleci/git_diffs.txt; then PROJECTS="languagetool-language-modules/fr/ $PROJECTS"; fi |
| 62 | + if grep -q -e "languagetool-language-modules/nl/.*" /home/circleci/git_diffs.txt; then PROJECTS="languagetool-language-modules/nl/ $PROJECTS"; fi |
| 63 | + if grep -q -e "languagetool-server/.*" /home/circleci/git_diffs.txt; then PROJECTS="languagetool-server/ $PROJECTS"; fi |
| 64 | +fi |
| 65 | +if [ -z "$PROJECTS" ]; then |
| 66 | + echo "No changes in any module detected" |
| 67 | + exit 0 |
| 68 | +else |
| 69 | + PROJECTS=${PROJECTS::-1} |
| 70 | +fi |
| 71 | +curl --request POST \ |
| 72 | + --url https://circleci.com/api/v2/project/gh/languagetooler-gmbh/languagetool-premium-modules/pipeline \ |
| 73 | + --header "Circle-Token: ${API_TOKEN}" \ |
| 74 | + --header "Content-Type: application/json" \ |
| 75 | + --data "{\"branch\":\"master\",\"parameters\":{\"run_on_pull\":false, \"os-sha\": \"'${CIRCLE_SHA1}'\", \"os-changes\":\"$PROJECTS\"}}" |
0 commit comments