From f31e580e52ad49035ecc016fd133004762d2e5ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Na=C3=AFm=20Favier?= Date: Mon, 17 Jan 2022 12:18:00 +0100 Subject: [PATCH] Clean up workflows (#415) * Clean up workflows * Rename workflow files * Temporarily enable workflows from PR * Add nixpkgs channel to NIX_PATH * Fix typo * Fix index names for warmup * Build verbosely * Fix index names again * Re-add jq * Revert "Temporarily enable workflows from PR" This reverts commit dd040e94645d9e61b80505471f57b1c0e35b1210. --- .github/workflows/cron-flakes.yml | 69 -------------------------- .github/workflows/cron-nixpkgs.yml | 72 ---------------------------- .github/workflows/frontend.yml | 15 +----- .github/workflows/import-flakes.yml | 60 +++++++++++++++++++++++ .github/workflows/import-nixpkgs.yml | 63 ++++++++++++++++++++++++ flake-info/src/elastic.rs | 2 +- 6 files changed, 125 insertions(+), 156 deletions(-) delete mode 100644 .github/workflows/cron-flakes.yml delete mode 100644 .github/workflows/cron-nixpkgs.yml create mode 100644 .github/workflows/import-flakes.yml create mode 100644 .github/workflows/import-nixpkgs.yml diff --git a/.github/workflows/cron-flakes.yml b/.github/workflows/cron-flakes.yml deleted file mode 100644 index ee01f3d..0000000 --- a/.github/workflows/cron-flakes.yml +++ /dev/null @@ -1,69 +0,0 @@ -name: "Flakes: Hourly import to Elasticsearch" - -on: - workflow_dispatch: - schedule: - - cron: '0 * * * *' - -jobs: - - hourly-import-channel: - - runs-on: ubuntu-latest - - strategy: - fail-fast: true - matrix: - group: - - "manual" - - env: - RUST_LOG: debug - FI_ES_EXISTS_STRATEGY: recreate - FI_ES_URL: ${{ secrets.ELASTICSEARCH_URL }} - - steps: - - - name: Checking out the repository - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Installing Nix - uses: cachix/install-nix-action@v16 - with: - install_url: https://nixos-nix-install-tests.cachix.org/serve/i6laym9jw3wg9mw6ncyrk6gjx4l34vvx/install - install_options: '--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve' - extra_nix_config: | - experimental-features = nix-command flakes - access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} - - - uses: cachix/cachix-action@v10 - with: - name: nixos-search - signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}' - - - name: Install unstable channel - run: | - nix-channel --add https://nixos.org/channels/nixpkgs-unstable - nix-channel --update - - - name: Installing jq - run: | - nix-env -iA nixpkgs.nixFlakes nixpkgs.jq - - - name: Building import_scripts - run: | - nix build ./#packages.x86_64-linux.flake-info - - - name: Import ${{ matrix.group }} group - run: | - ./result/bin/flake-info --push --elastic-schema-version=$(cat ./VERSION) group ./flakes/${{ matrix.group }}.toml ${{ matrix.group }} - if: github.repository == 'NixOS/nixos-search' - - - name: Warmup ${{ matrix.group }} channel - run: | - curl ${{ secrets.ELASTICSEARCH_URL }}/$(cat VERSION)-${{ matrix.group }}/_search | jq '.took' - curl ${{ secrets.ELASTICSEARCH_URL }}/$(cat VERSION)-${{ matrix.group }}/_search | jq '.took' - curl ${{ secrets.ELASTICSEARCH_URL }}/$(cat VERSION)-${{ matrix.group }}/_search | jq '.took' - if: github.repository == 'NixOS/nixos-search' diff --git a/.github/workflows/cron-nixpkgs.yml b/.github/workflows/cron-nixpkgs.yml deleted file mode 100644 index 0823d06..0000000 --- a/.github/workflows/cron-nixpkgs.yml +++ /dev/null @@ -1,72 +0,0 @@ -name: "Nixpkgs: Hourly import to Elasticsearch" - -on: - workflow_dispatch: - schedule: - - cron: '0 * * * *' - -jobs: - - import-channel: - - runs-on: ubuntu-latest - - strategy: - fail-fast: true - matrix: - channel: - - unstable - - 21.11 - - 21.05 - - 20.09 - - env: - RUST_LOG: debug - FI_ES_EXISTS_STRATEGY: abort - FI_ES_URL: ${{ secrets.ELASTICSEARCH_URL }} - - steps: - - - name: Checking out the repository - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Installing Nix - uses: cachix/install-nix-action@v16 - with: - install_url: https://nixos-nix-install-tests.cachix.org/serve/i6laym9jw3wg9mw6ncyrk6gjx4l34vvx/install - install_options: '--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve' - extra_nix_config: | - experimental-features = nix-command flakes - access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} - - - uses: cachix/cachix-action@v10 - with: - name: nixos-search - signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}' - - - name: Install unstable channel - run: | - nix-channel --add https://nixos.org/channels/nixpkgs-unstable - nix-channel --update - - - name: Installing jq - run: | - nix-env -iA nixpkgs.nixFlakes nixpkgs.jq - - - name: Building import_scripts - run: | - nix build ./#packages.x86_64-linux.flake-info - - - name: Import ${{ matrix.channel }} channel - run: | - ./result/bin/flake-info --push --elastic-schema-version=$(cat ./VERSION) nixpkgs ${{ matrix.channel }} - if: github.repository == 'NixOS/nixos-search' - - - name: Warmup ${{ matrix.channel }} channel - run: | - curl ${{ secrets.ELASTICSEARCH_URL }}/latest-$(cat VERSION)-nixpkgs-${{ matrix.channel }}/_search | jq '.took' - curl ${{ secrets.ELASTICSEARCH_URL }}/latest-$(cat VERSION)-nixpkgs-${{ matrix.channel }}/_search | jq '.took' - curl ${{ secrets.ELASTICSEARCH_URL }}/latest-$(cat VERSION)-nixpkgs-${{ matrix.channel }}/_search | jq '.took' - if: github.repository == 'NixOS/nixos-search' diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml index a2e163f..5283745 100644 --- a/.github/workflows/frontend.yml +++ b/.github/workflows/frontend.yml @@ -21,22 +21,9 @@ jobs: name: nixos-search signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}' - - name: Install unstable channel - run: | - nix-channel --add https://nixos.org/channels/nixpkgs-unstable - nix-channel --update - - - name: Installing NixFlakes - run: | - nix-env -iA nixpkgs.nixFlakes - echo 'experimental-features = nix-command flakes' | sudo tee -a /etc/nix/nix.conf - nix --version - cat /etc/nix/nix.conf - echo "$HOME/.nix-profile/bin" >> $GITHUB_PATH - - name: Building search.nixos.org run: | - nix build ./#packages.x86_64-linux.frontend + nix -vL build .#frontend mkdir ./dist cp -RL ./result/* ./dist/ diff --git a/.github/workflows/import-flakes.yml b/.github/workflows/import-flakes.yml new file mode 100644 index 0000000..3b68f23 --- /dev/null +++ b/.github/workflows/import-flakes.yml @@ -0,0 +1,60 @@ +name: "Flakes: Hourly import to Elasticsearch" + +on: + workflow_dispatch: + schedule: + - cron: '0 * * * *' + +jobs: + + import-flakes: + + runs-on: ubuntu-latest + + strategy: + fail-fast: true + matrix: + group: + - "manual" + + env: + RUST_LOG: debug + FI_ES_EXISTS_STRATEGY: recreate + FI_ES_URL: ${{ secrets.ELASTICSEARCH_URL }} + + steps: + + - name: Checking out the repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Installing Nix + uses: cachix/install-nix-action@v16 + with: + nix_path: nixpkgs=channel:nixpkgs-unstable + + - uses: cachix/cachix-action@v10 + with: + name: nixos-search + signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}' + + - name: Installing jq + run: | + nix-env -f '' -iA jq + + - name: Building flake-info + run: | + nix -vL build .#flake-info + + - name: Import ${{ matrix.group }} group + run: | + ./result/bin/flake-info --push --elastic-schema-version=$(< ./VERSION) group ./flakes/${{ matrix.group }}.toml ${{ matrix.group }} + if: github.repository_owner == 'NixOS' + + - name: Warmup ${{ matrix.group }} group + run: | + for (( i = 0; i < 3; i++ )) do + curl -sS ${{ secrets.ELASTICSEARCH_URL }}/latest-$(< VERSION)-group-${{ matrix.group }}/_search | jq -c '.took // .' + done + if: github.repository_owner == 'NixOS' diff --git a/.github/workflows/import-nixpkgs.yml b/.github/workflows/import-nixpkgs.yml new file mode 100644 index 0000000..61f5486 --- /dev/null +++ b/.github/workflows/import-nixpkgs.yml @@ -0,0 +1,63 @@ +name: "Nixpkgs: Hourly import to Elasticsearch" + +on: + workflow_dispatch: + schedule: + - cron: '0 * * * *' + +jobs: + + import-nixpkgs: + + runs-on: ubuntu-latest + + strategy: + fail-fast: true + matrix: + channel: + - unstable + - 21.11 + - 21.05 + - 20.09 + + env: + RUST_LOG: debug + FI_ES_EXISTS_STRATEGY: abort + FI_ES_URL: ${{ secrets.ELASTICSEARCH_URL }} + + steps: + + - name: Checking out the repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Installing Nix + uses: cachix/install-nix-action@v16 + with: + nix_path: nixpkgs=channel:nixpkgs-unstable + + - uses: cachix/cachix-action@v10 + with: + name: nixos-search + signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}' + + - name: Installing jq + run: | + nix-env -f '' -iA jq + + - name: Building flake-info + run: | + nix -vL build .#flake-info + + - name: Import ${{ matrix.channel }} channel + run: | + ./result/bin/flake-info --push --elastic-schema-version=$(< VERSION) nixpkgs ${{ matrix.channel }} + if: github.repository_owner == 'NixOS' + + - name: Warmup ${{ matrix.channel }} channel + run: | + for (( i = 0; i < 3; i++ )) do + curl -sS ${{ secrets.ELASTICSEARCH_URL }}/latest-$(< VERSION)-nixos-${{ matrix.channel }}/_search | jq -c '.took // .' + done + if: github.repository_owner == 'NixOS' diff --git a/flake-info/src/elastic.rs b/flake-info/src/elastic.rs index 2bd20c9..e8b8bb7 100644 --- a/flake-info/src/elastic.rs +++ b/flake-info/src/elastic.rs @@ -382,7 +382,7 @@ impl Elasticsearch { alias: &str, ) -> Result<(), ElasticsearchError> { // delete old alias - info!("Try deletig old alias"); + info!("Try deleting old alias"); let response = self .client .indices()