Skip to content

2-hourly import to Elasticsearch #37328

2-hourly import to Elasticsearch

2-hourly import to Elasticsearch #37328

name: "2-hourly import to Elasticsearch"
on:
workflow_dispatch:
schedule:
- cron: "0 */2 * * *"
permissions:
contents: read
jobs:
nixos-channels:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.nixos-channels.outputs.matrix }}
steps:
- name: Checking out the repository
uses: actions/checkout@v7.0.1
- name: Setup
uses: ./.github/actions/common-setup
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CACHIX_SIGNING_KEY: ${{ secrets.CACHIX_SIGNING_KEY }}
- name: NixOS Channels
id: nixos-channels
shell: sh
run: |
nix build --accept-flake-config -L .#nixosChannels
channels="{\"channel\": $(cat ./result)}"
echo "$channels"
echo "matrix=$channels" >> "$GITHUB_OUTPUT"
import-nixpkgs:
needs: nixos-channels
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.nixos-channels.outputs.matrix) }}
permissions:
issues: write
env:
RUST_LOG: debug
FI_ES_EXISTS_STRATEGY: abort
FI_ES_URL: ${{ secrets.ELASTICSEARCH_URL2 }}
steps:
- name: Checking out the repository
uses: actions/checkout@v7.0.1
- name: Setup
uses: ./.github/actions/common-setup
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CACHIX_SIGNING_KEY: ${{ secrets.CACHIX_SIGNING_KEY }}
- name: Compute cache date
id: date
shell: sh
run: echo "date=$(date -u +%F)" >> "$GITHUB_OUTPUT"
- name: Restore Repology counts from cache
uses: actions/cache/restore@v6
with:
path: repology-counts.json
# Falls back to the newest available daily cache; a total miss (e.g. a
# branch outside the default-branch cache scope) leaves the file
# absent, and the importer warns and drops the Repology signal.
key: repology-counts-v1-${{ steps.date.outputs.date }}
restore-keys: |
repology-counts-v1-
- name: Import ${{ matrix.channel }} channel
if: github.repository_owner == 'NixOS'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: sh
run: |
nix run --accept-flake-config .#flake-info -- --push --elastic-schema-version=$(nix eval --raw --file ./version.nix import) --save-summary $GITHUB_STEP_SUMMARY nixpkgs ${{ matrix.channel }} --repology-counts-file repology-counts.json
- name: Warmup ${{ matrix.channel }} channel
if: github.repository_owner == 'NixOS'
shell: sh
run: |
for i in 1 2 3
do
curl -sS ${{ secrets.ELASTICSEARCH_URL2 }}/latest-$(nix eval --raw --file ./version.nix import)-nixos-${{ matrix.channel }}/_search | jq -ce '.took // error'
done
- name: Create issue if failed
if: failure()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
shell: sh
run: |
TITLE="Failing import for nixpkgs ${{ matrix.channel }}"
if [ "$(gh issue list --state open --search "in:title $TITLE" -L 1 --json id --jq length)" -eq 0 ]; then
gh issue create \
--title "$TITLE" \
--label "prio:blocker" \
--body "This issue was triggered by ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
fi
import-flakes:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
group:
- "manual"
permissions:
issues: write
env:
RUST_LOG: debug
FI_ES_EXISTS_STRATEGY: recreate
FI_ES_URL: ${{ secrets.ELASTICSEARCH_URL2 }}
steps:
- name: Checking out the repository
uses: actions/checkout@v7.0.1
- name: Setup
uses: ./.github/actions/common-setup
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CACHIX_SIGNING_KEY: ${{ secrets.CACHIX_SIGNING_KEY }}
- name: Import ${{ matrix.group }} group
if: github.repository_owner == 'NixOS'
shell: sh
run: |
nix run --accept-flake-config .#flake-info -- --push --elastic-schema-version=$(nix eval --raw --file ./version.nix import) --save-summary $GITHUB_STEP_SUMMARY group ./flakes/${{ matrix.group }}.toml ${{ matrix.group }} --with-gc
- name: Warmup ${{ matrix.group }} group
if: github.repository_owner == 'NixOS'
shell: sh
run: |
for i in 1 2 3
do
curl -sS ${{ secrets.ELASTICSEARCH_URL2 }}/latest-$(nix eval --raw --file ./version.nix import)-group-${{ matrix.group }}/_search | jq -c '.took // .'
done
- name: Create issue if failed
if: failure()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
shell: sh
run: |
TITLE="Failing import for ${{ matrix.group }} group"
if [ "$(gh issue list --state open --search "in:title $TITLE" -L 1 --json id --jq length)" -eq 0 ]; then
gh issue create \
--title "$TITLE" \
--label "prio:blocker" \
--body "This issue was triggered by ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
fi