2020-05-22 22:13:55 +00:00
|
|
|
name: "Hourly import channel to Elasticsearch"
|
2020-06-19 18:16:11 +00:00
|
|
|
|
2020-05-22 22:13:55 +00:00
|
|
|
on:
|
2020-06-19 18:16:11 +00:00
|
|
|
|
2020-05-22 22:13:55 +00:00
|
|
|
schedule:
|
|
|
|
- cron: '0 * * * *'
|
2020-06-19 18:16:11 +00:00
|
|
|
|
2020-05-22 22:13:55 +00:00
|
|
|
jobs:
|
2020-06-19 18:16:11 +00:00
|
|
|
|
2020-05-22 22:13:55 +00:00
|
|
|
hourly-import-channel:
|
2020-06-19 18:16:11 +00:00
|
|
|
|
2020-05-22 22:13:55 +00:00
|
|
|
runs-on: ubuntu-latest
|
2020-06-19 18:16:11 +00:00
|
|
|
|
2020-05-22 22:13:55 +00:00
|
|
|
strategy:
|
2020-06-19 18:16:11 +00:00
|
|
|
fail-fast: true
|
2020-05-22 22:13:55 +00:00
|
|
|
matrix:
|
|
|
|
channel:
|
2020-06-15 08:26:19 +00:00
|
|
|
- unstable
|
2021-06-08 11:43:01 +00:00
|
|
|
- 21.05
|
2020-09-24 20:29:47 +00:00
|
|
|
- 20.09
|
2020-06-19 18:16:11 +00:00
|
|
|
|
|
|
|
env:
|
2020-11-30 18:16:14 +00:00
|
|
|
AWS_DEFAULT_REGION: us-east-1
|
|
|
|
AWS_S3_URL: s3://nix-releases/nixpkgs
|
2020-06-19 18:16:11 +00:00
|
|
|
|
2020-05-22 22:13:55 +00:00
|
|
|
steps:
|
2020-06-19 18:16:11 +00:00
|
|
|
|
2020-05-22 22:13:55 +00:00
|
|
|
- name: Checking out the repository
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
2020-06-18 22:41:01 +00:00
|
|
|
|
2020-07-24 12:41:34 +00:00
|
|
|
- name: Installing Nix
|
2021-06-08 11:51:46 +00:00
|
|
|
uses: cachix/install-nix-action@v13
|
2020-07-24 12:41:34 +00:00
|
|
|
|
2021-06-08 11:51:46 +00:00
|
|
|
- uses: cachix/cachix-action@v10
|
2020-08-28 20:57:06 +00:00
|
|
|
with:
|
|
|
|
name: nixos-search
|
|
|
|
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
|
|
|
|
|
2020-11-17 08:58:25 +00:00
|
|
|
- name: Install unstable channel
|
|
|
|
run: |
|
|
|
|
nix-channel --add https://nixos.org/channels/nixpkgs-unstable
|
|
|
|
nix-channel --update
|
|
|
|
|
2020-07-24 12:41:34 +00:00
|
|
|
- name: Installing awscli
|
|
|
|
run: |
|
2020-11-23 22:56:59 +00:00
|
|
|
nix-env -iA nixpkgs.awscli2
|
2020-07-24 12:41:34 +00:00
|
|
|
|
2020-06-19 18:16:11 +00:00
|
|
|
- name: Check for latest evaluation in ${{ matrix.channel }} channel
|
|
|
|
run: |
|
|
|
|
if [ "${{ matrix.channel }}" = "unstable" ]; then
|
2020-11-30 18:16:14 +00:00
|
|
|
RELEASE=$(aws s3 ls --no-sign-request "$AWS_S3_URL/" | grep '/$' | cut -d' ' -f29 | sort | tail -1 | sed 's|/||')
|
2020-06-19 18:16:11 +00:00
|
|
|
else
|
2020-11-30 18:16:14 +00:00
|
|
|
RELEASE=$(aws s3 ls --no-sign-request "$AWS_S3_URL/" | grep 'nixpkgs-${{ matrix.channel }}pre' | grep '/$' | cut -d' ' -f29 | sort | tail -1 | sed 's|/||')
|
2020-06-19 18:16:11 +00:00
|
|
|
fi
|
2020-11-30 18:16:14 +00:00
|
|
|
aws s3 cp --no-sign-request "$AWS_S3_URL/$RELEASE/src-url" ./
|
|
|
|
EVAL_ID=$(cat src-url | cut -c30-)
|
|
|
|
echo "EVAL_ID=${EVAL_ID}" >> $GITHUB_ENV
|
2020-06-19 18:16:11 +00:00
|
|
|
|
|
|
|
- name: Download latest builds for ${{ matrix.channel }} channel (if needed)
|
|
|
|
if: steps.eval-cache.outputs.cache-hit != 'true'
|
|
|
|
run: |
|
|
|
|
mkdir -p ./eval-cache
|
|
|
|
cp ./src-url ./eval-cache/
|
|
|
|
curl -H "Content-Type: application/json" "$(cat ./eval-cache/src-url)/builds" -o ./eval-cache/builds.json
|
|
|
|
|
2020-07-24 12:41:34 +00:00
|
|
|
- name: Cache ${{ matrix.channel }} channel builds
|
|
|
|
id: eval-cache
|
|
|
|
uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: ./eval-cache
|
|
|
|
key: eval-cache-${{ env.EVAL_ID }}
|
2020-06-18 22:41:01 +00:00
|
|
|
|
2021-02-07 18:10:13 +00:00
|
|
|
- name: Installing nixFlakes (and jq)
|
2020-06-18 22:41:01 +00:00
|
|
|
run: |
|
2021-02-07 18:10:13 +00:00
|
|
|
nix-env -iA nixpkgs.nixFlakes nixpkgs.jq
|
2020-06-18 22:41:01 +00:00
|
|
|
echo 'experimental-features = nix-command flakes' | sudo tee -a /etc/nix/nix.conf
|
2020-12-17 13:05:55 +00:00
|
|
|
nix --version
|
2020-06-18 22:41:01 +00:00
|
|
|
cat /etc/nix/nix.conf
|
2020-12-17 13:05:55 +00:00
|
|
|
echo "$HOME/.nix-profile/bin" >> $GITHUB_PATH
|
2020-06-18 22:41:01 +00:00
|
|
|
|
|
|
|
- name: Building import_scripts
|
|
|
|
run: |
|
2020-12-17 13:05:55 +00:00
|
|
|
nix build ./#packages.x86_64-linux.import_scripts
|
2020-06-18 22:41:01 +00:00
|
|
|
|
2020-05-22 22:13:55 +00:00
|
|
|
- name: Import ${{ matrix.channel }} channel
|
|
|
|
run: |
|
2020-06-19 18:16:11 +00:00
|
|
|
cp ./eval-cache/builds.json ./eval-${{ env.EVAL_ID }}.json
|
2020-06-18 22:41:01 +00:00
|
|
|
./result/bin/import-channel --es-url ${{ secrets.ELASTICSEARCH_URL }} --channel ${{ matrix.channel }} -vvv
|
2020-05-22 22:13:55 +00:00
|
|
|
if: github.repository == 'NixOS/nixos-search'
|
2021-02-07 18:10:13 +00:00
|
|
|
|
|
|
|
- name: Warmup ${{ matrix.channel }} channel
|
|
|
|
run: |
|
|
|
|
curl ${{ secrets.ELASTICSEARCH_URL }}/latest-$(cat VERSION)-${{ matrix.channel }}/_search | jq '.took'
|
|
|
|
curl ${{ secrets.ELASTICSEARCH_URL }}/latest-$(cat VERSION)-${{ matrix.channel }}/_search | jq '.took'
|
|
|
|
curl ${{ secrets.ELASTICSEARCH_URL }}/latest-$(cat VERSION)-${{ matrix.channel }}/_search | jq '.took'
|
|
|
|
if: github.repository == 'NixOS/nixos-search'
|