diff --git a/.travis.yml b/.travis.yml index 640d5066e..a1b67c308 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,12 +11,14 @@ notifications: jobs: include: - - name: deploy to nur-combined - script: bash ci/deploy.sh - if: branch = master + - name: test pull request + script: bash ci/test.sh + if: type = pull_request + + - name: update nur / nur-combined + script: bash ci/update-nur.sh + if: branch = master AND type != pull_request - name: update nur-search/data/packages.json script: ci/update-nur-search.sh - if: branch = master - - + if: branch = master AND type != pull_request diff --git a/ci/lib/setup-git.sh b/ci/lib/setup-git.sh index 163a0819c..2b1725f34 100644 --- a/ci/lib/setup-git.sh +++ b/ci/lib/setup-git.sh @@ -22,4 +22,3 @@ git config --global user.name "Nur a bot" git config --global user.email "joerg.nur-bot@thalheim.io" git config --global user.signingkey "B4E40EEC9053254E" git config --global commit.gpgsign true - diff --git a/ci/lib/travis-functions.sh b/ci/lib/travis-functions.sh deleted file mode 100644 index 7197eb039..000000000 --- a/ci/lib/travis-functions.sh +++ /dev/null @@ -1,32 +0,0 @@ -# only source this file -# to load functions that help with travis.ci -# ========================================== - - -is-automatic-update() { - [[ "$TRAVIS_EVENT_TYPE" == "cron" ]] || [[ "$TRAVIS_EVENT_TYPE" == "api" ]] -} - -is-pull-request(){ - [[ "$TRAVIS_PULL_REQUEST" != "false" ]] -} - -is-not-pull-request(){ - [[ "$TRAVIS_PULL_REQUEST" = "false" ]] -} - -dont-continue-on-pull-requests() { - if is-pull-request - then - echo "stopping because this is a pull request" - exit 0 - fi -} - -only-continue-on-pull-requests() { - if is-not-pull-request - then - echo "stopping because this is not a pull request" - exit 0 - fi -} diff --git a/ci/lint.sh b/ci/lint.sh deleted file mode 100755 index 5bed39c7d..000000000 --- a/ci/lint.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash - -set -eu -o pipefail # Exit with nonzero exit code if anything fails - -$(nix-build --no-out-link release.nix)/bin/nur format-manifest -if [ -n "$(git diff --exit-code repos.json)" ]; then - echo "repos.json was not formatted before committing repos.json:" >&2 - git diff --exit-code repos.json - echo "Please run ./bin/nur/format-manifest.py and updates repos.json accordingly!" >&2 - exit 1 -fi - -# Type checker -nix run nixpkgs.python3Packages.mypy -c mypy nur -# Format checker -nix run nixpkgs.python3Packages.black -c black --check . -# Linter -nix run nixpkgs.python3Packages.flake8 -c flake8 . diff --git a/ci/test.sh b/ci/test.sh new file mode 100755 index 000000000..b41105b6f --- /dev/null +++ b/ci/test.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +set -eux -o pipefail # Exit with nonzero exit code if anything fails + +nix run '(import ./release.nix {})' -c nur format-manifest +if [ -n "$(git diff --exit-code repos.json)" ]; then + echo "repos.json was not formatted before committing repos.json:" >&2 + git diff --exit-code repos.json + echo "Please run ./bin/nur/format-manifest.py and updates repos.json accordingly!" >&2 + exit 1 +fi + +# Type checker +nix run nixpkgs.python3Packages.mypy -c mypy nur +# Format checker +nix run nixpkgs.python3Packages.black -c black --check . +# Linter +nix run nixpkgs.python3Packages.flake8 -c flake8 . + +nix run '(import ./release.nix {})' -c nur update +nix-build diff --git a/ci/update-nur-search.sh b/ci/update-nur-search.sh index 51835b935..b4a536d37 100755 --- a/ci/update-nur-search.sh +++ b/ci/update-nur-search.sh @@ -4,11 +4,8 @@ set -eu -o pipefail # Exit with nonzero exit code if anything fails DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" -source ${DIR}/lib/travis-functions.sh - -dont-continue-on-pull-requests - source ${DIR}/lib/setup-git.sh +set -x # build package.json for nur-search @@ -18,7 +15,7 @@ nix-build --quiet release.nix git clone git@github.com:nix-community/nur-search -result/bin/nur index . > nur-search/data/packages.json +nix run '(import ./release.nix {})' -c nur index . > nur-search/data/packages.json # rebuild and publish nur-search repository # ----------------------------------------- diff --git a/ci/deploy.sh b/ci/update-nur.sh similarity index 70% rename from ci/deploy.sh rename to ci/update-nur.sh index bc1788d5a..fd85b9aa0 100755 --- a/ci/deploy.sh +++ b/ci/update-nur.sh @@ -4,27 +4,15 @@ set -eu -o pipefail # Exit with nonzero exit code if anything fails DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" -source ${DIR}/lib/travis-functions.sh - -nix-build --quiet release.nix - -if ! is-automatic-update; then - source $DIR/lint.sh -fi - +source ${DIR}/lib/setup-git.sh set -x -result/bin/nur update +nix run '(import ./release.nix {})' -c nur update nix-build -# Move everything below to a different job -dont-continue-on-pull-requests - -source ${DIR}/lib/setup-git.sh - git clone git@github.com:nix-community/nur-combined -result/bin/nur combine \ +nix run '(import ./release.nix {})' -c nur combine \ --irc-notify nur-bot@chat.freenode.net:6697/nixos-nur \ nur-combined