From d8f72669b79a5cebbd9738d16ac8d8a556519c3e Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Thu, 12 Mar 2020 01:31:48 +0800 Subject: [PATCH 1/5] add irc notifications --- .travis.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.travis.yml b/.travis.yml index 46c2cb35b..337ec47f1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,12 @@ language: nix script: - bash ci/deploy.sh + +notifications: + irc: + on_success: change + on_failure: always + channels: + - "irc.freenode.net#nixos-nur" + template: + - "%{result} - %{branch} \"%{commit_subject}\" %{build_url}" From 8aae37c250aa92f2a97bfe57368b3d8428ee2ac5 Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Thu, 12 Mar 2020 01:32:27 +0800 Subject: [PATCH 2/5] update-nur-search.sh: add script to deploy package.json --- .travis.yml | 14 ++++++++++++-- ci/deploy.sh | 35 +++-------------------------------- ci/lib/setup-git.sh | 25 +++++++++++++++++++++++++ ci/lib/travis-functions.sh | 32 ++++++++++++++++++++++++++++++++ ci/update-nur-search.sh | 34 ++++++++++++++++++++++++++++++++++ 5 files changed, 106 insertions(+), 34 deletions(-) create mode 100644 ci/lib/setup-git.sh create mode 100644 ci/lib/travis-functions.sh create mode 100755 ci/update-nur-search.sh diff --git a/.travis.yml b/.travis.yml index 337ec47f1..640d5066e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,4 @@ language: nix -script: - - bash ci/deploy.sh notifications: irc: @@ -10,3 +8,15 @@ notifications: - "irc.freenode.net#nixos-nur" template: - "%{result} - %{branch} \"%{commit_subject}\" %{build_url}" + +jobs: + include: + - name: deploy to nur-combined + script: bash ci/deploy.sh + if: branch = master + + - name: update nur-search/data/packages.json + script: ci/update-nur-search.sh + if: branch = master + + diff --git a/ci/deploy.sh b/ci/deploy.sh index 1bcb8262f..242eb7fff 100755 --- a/ci/deploy.sh +++ b/ci/deploy.sh @@ -4,27 +4,8 @@ set -eu -o pipefail # Exit with nonzero exit code if anything fails DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" -is-automatic-update() { - [[ "$TRAVIS_EVENT_TYPE" == "cron" ]] || [[ "$TRAVIS_EVENT_TYPE" == "api" ]] -} - -if is-automatic-update; then - keys_dir=$(mktemp -d) - openssl aes-256-cbc \ - -K $encrypted_080f214a372c_key \ - -iv $encrypted_080f214a372c_iv \ - -in ci/keys.tar.gz.enc -out ci/keys.tar.gz -d - tar -C "$keys_dir" -xzvf ci/keys.tar.gz - - eval "$(ssh-agent -s)" - - chmod 600 "${keys_dir}/ssh-key" - ssh-add "${keys_dir}/ssh-key" - gpg --import "${keys_dir}/gpg-private-key" - rm -rf "$keys_dir" -fi - -export encrypted_080f214a372c_key= encrypted_080f214a372c_iv= +source ${DIR}/lib/travis-functions.sh +source ${DIR}/lib/setup-git.sh nix-build --quiet release.nix @@ -37,16 +18,7 @@ set -x result/bin/nur update nix-build -if ! is-automatic-update; then - # Pull requests and commits to other branches shouldn't try to deploy, just build to verify - echo "Skipping deploy; just doing a build." - exit 0 -fi - -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 +dont-continue-on-pull-requests git clone git@github.com:nix-community/nur-combined @@ -58,7 +30,6 @@ if [[ -z "$(git diff --exit-code)" ]]; then echo "No changes to the output on this push; exiting." else git add --all repos.json* - git commit -m "automatic update" git push git@github.com:nix-community/NUR HEAD:master fi diff --git a/ci/lib/setup-git.sh b/ci/lib/setup-git.sh new file mode 100644 index 000000000..163a0819c --- /dev/null +++ b/ci/lib/setup-git.sh @@ -0,0 +1,25 @@ +# only source this file +# to setup git to push and pull repositories via ssh +# ================================================== + +# set up git and ssh +# ------------------ +keys_dir=$(mktemp -d) +openssl aes-256-cbc \ + -K $encrypted_080f214a372c_key \ + -iv $encrypted_080f214a372c_iv \ + -in ci/keys.tar.gz.enc -out ci/keys.tar.gz -d +tar -C "$keys_dir" -xzvf ci/keys.tar.gz +eval "$(ssh-agent -s)" +chmod 600 "${keys_dir}/ssh-key" +ssh-add "${keys_dir}/ssh-key" +gpg --import "${keys_dir}/gpg-private-key" +rm -rf "$keys_dir" + +export encrypted_080f214a372c_key= encrypted_080f214a372c_iv= + +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 new file mode 100644 index 000000000..7197eb039 --- /dev/null +++ b/ci/lib/travis-functions.sh @@ -0,0 +1,32 @@ +# 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/update-nur-search.sh b/ci/update-nur-search.sh new file mode 100755 index 000000000..51835b935 --- /dev/null +++ b/ci/update-nur-search.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +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 + + +# build package.json for nur-search +# --------------------------------- + +nix-build --quiet release.nix + +git clone git@github.com:nix-community/nur-search + +result/bin/nur index . > nur-search/data/packages.json + +# rebuild and publish nur-search repository +# ----------------------------------------- + +cd nur-search +if [[ ! -z "$(git diff --exit-code)" ]]; then + git add ./data/packages.json + git commit -m "automatic update package.json" + git push origin master + nix-shell --run "make && make publish" +else + echo "nothings changed will not commit anything" +fi From 70a4358cfe1751ff0956496332e76b93222ce361 Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Thu, 12 Mar 2020 01:48:53 +0800 Subject: [PATCH 3/5] update README --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 53cf22fc3..3528e36c8 100644 --- a/README.md +++ b/README.md @@ -134,9 +134,11 @@ in ## Finding packages -At the moment we do not have a dedicated package search available. However our -[nur-combined](https://github.com/nix-community/nur-combined) repository contains all -nix expressions from all users and can be search via +You can find all packages using +[Packages search for NUR](https://nix-community.github.io/nur-search/) +or search our +[nur-combined](https://github.com/nix-community/nur-combined) +repository, which contains all nix expressions from all users, via [github](https://github.com/nix-community/nur-combined/search). ## How to add your own repository. From 19b5bfb47c3d2848ee3f09e61041460fed20759f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Thu, 12 Mar 2020 14:01:10 +0000 Subject: [PATCH 4/5] ci: only setup git/gpg on master builds --- ci/deploy.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ci/deploy.sh b/ci/deploy.sh index 242eb7fff..bc1788d5a 100755 --- a/ci/deploy.sh +++ b/ci/deploy.sh @@ -5,12 +5,11 @@ 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 -source ${DIR}/lib/setup-git.sh nix-build --quiet release.nix if ! is-automatic-update; then - bash $DIR/lint.sh + source $DIR/lint.sh fi set -x @@ -18,8 +17,11 @@ set -x result/bin/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 \ From 64d5a2a9ab5fd09bd97ee605a6c0c6d2952f3a2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Thu, 12 Mar 2020 16:04:53 +0000 Subject: [PATCH 5/5] ci: split nur update from pr testing --- .travis.yml | 14 ++++++++------ ci/lib/setup-git.sh | 1 - ci/lib/travis-functions.sh | 32 -------------------------------- ci/lint.sh | 18 ------------------ ci/test.sh | 21 +++++++++++++++++++++ ci/update-nur-search.sh | 7 ++----- ci/{deploy.sh => update-nur.sh} | 18 +++--------------- 7 files changed, 34 insertions(+), 77 deletions(-) delete mode 100644 ci/lib/travis-functions.sh delete mode 100755 ci/lint.sh create mode 100755 ci/test.sh rename ci/{deploy.sh => update-nur.sh} (70%) 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