Loading .github/workflows/ci.yml +8 −3 Original line number Diff line number Diff line Loading @@ -13,7 +13,12 @@ jobs: - uses: actions/checkout@v2 with: fetch-depth: 0 - run: git clone --depth 1 https://github.com/sstephenson/bats.git - run: PATH="./bats/bin:$PATH" script/test - name: Install bats run: git clone --depth 1 https://github.com/sstephenson/bats.git - name: Run tests run: PATH="./bats/bin:$PATH" script/test - name: Verify download URL checksums if: github.event_name == 'pull_request' run: ./script/mirror verify "$COMMIT_RANGE" env: COMMIT_RANGE: ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} COMMIT_RANGE: ${{ github.event.pull_request.base.sha }}.. .github/workflows/mirror.yml 0 → 100644 +18 −0 Original line number Diff line number Diff line name: Mirror on: push jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 with: fetch-depth: 0 - name: Update download mirror run: script/mirror update "${BEFORE_REF}.." env: BEFORE_REF: ${{ github.event.push.before }} AMAZON_S3_BUCKET: ruby-build-mirror AWS_ACCESS_KEY_ID: AKIAJKAUQVHU6X4CODDQ AWS_SECRET_ACCESS_KEY: ${{ secrets.MIRROR_UPLOAD_SECRET }} script/mirror +12 −5 Original line number Diff line number Diff line Loading @@ -53,31 +53,38 @@ update() { local url local checksum local file local tmp_path for url in $(potentially_new_packages "$1"); do checksum="${url#*#}" url="${url%#*}" if test_mirrored "$checksum"; then echo "Already mirrored: $url" else echo "Mirroring: $url" file="${TMPDIR:-/tmp}/$checksum" echo "Will mirror: $url" [ -n "$tmp_path" ] || tmp_path="$(mktemp -d "${TMPDIR:-/tmp}/s3-sync.XXXXX")" file="$tmp_path/$checksum" download_and_verify "$url" "$file" "$checksum" ./script/s3-put "$file" "${AMAZON_S3_BUCKET?}" fi done if [ -n "$tmp_path" ]; then echo "Uploading..." aws s3 sync --acl=public-read --size-only "$tmp_path" "s3://${AMAZON_S3_BUCKET?}" fi } verify() { local url local checksum local file local status=0 for url in $(potentially_new_packages "$1"); do checksum="${url#*#}" url="${url%#*}" echo "Verifying checksum for $url" file="${TMPDIR:-/tmp}/$checksum" download_and_verify "$url" "$file" "$checksum" download_and_verify "$url" "$file" "$checksum" || status=$? done return $status } stats() { Loading @@ -88,7 +95,7 @@ stats() { for url in "${packages[@]}"; do checksum="${url#*#}" if test_mirrored "$checksum"; then confirmed="$((confirmed + 1))" : $((confirmed++)) else echo "failed: $url" >&2 fi Loading script/test +2 −10 Original line number Diff line number Diff line #!/usr/bin/env bash #!/bin/bash set -e set -x STATUS=0 bats ${CI:+--tap} test || STATUS="$?" if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then ./script/mirror verify "$COMMIT_RANGE" fi exit "$STATUS" bats ${CI:+--tap} test Loading
.github/workflows/ci.yml +8 −3 Original line number Diff line number Diff line Loading @@ -13,7 +13,12 @@ jobs: - uses: actions/checkout@v2 with: fetch-depth: 0 - run: git clone --depth 1 https://github.com/sstephenson/bats.git - run: PATH="./bats/bin:$PATH" script/test - name: Install bats run: git clone --depth 1 https://github.com/sstephenson/bats.git - name: Run tests run: PATH="./bats/bin:$PATH" script/test - name: Verify download URL checksums if: github.event_name == 'pull_request' run: ./script/mirror verify "$COMMIT_RANGE" env: COMMIT_RANGE: ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} COMMIT_RANGE: ${{ github.event.pull_request.base.sha }}..
.github/workflows/mirror.yml 0 → 100644 +18 −0 Original line number Diff line number Diff line name: Mirror on: push jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 with: fetch-depth: 0 - name: Update download mirror run: script/mirror update "${BEFORE_REF}.." env: BEFORE_REF: ${{ github.event.push.before }} AMAZON_S3_BUCKET: ruby-build-mirror AWS_ACCESS_KEY_ID: AKIAJKAUQVHU6X4CODDQ AWS_SECRET_ACCESS_KEY: ${{ secrets.MIRROR_UPLOAD_SECRET }}
script/mirror +12 −5 Original line number Diff line number Diff line Loading @@ -53,31 +53,38 @@ update() { local url local checksum local file local tmp_path for url in $(potentially_new_packages "$1"); do checksum="${url#*#}" url="${url%#*}" if test_mirrored "$checksum"; then echo "Already mirrored: $url" else echo "Mirroring: $url" file="${TMPDIR:-/tmp}/$checksum" echo "Will mirror: $url" [ -n "$tmp_path" ] || tmp_path="$(mktemp -d "${TMPDIR:-/tmp}/s3-sync.XXXXX")" file="$tmp_path/$checksum" download_and_verify "$url" "$file" "$checksum" ./script/s3-put "$file" "${AMAZON_S3_BUCKET?}" fi done if [ -n "$tmp_path" ]; then echo "Uploading..." aws s3 sync --acl=public-read --size-only "$tmp_path" "s3://${AMAZON_S3_BUCKET?}" fi } verify() { local url local checksum local file local status=0 for url in $(potentially_new_packages "$1"); do checksum="${url#*#}" url="${url%#*}" echo "Verifying checksum for $url" file="${TMPDIR:-/tmp}/$checksum" download_and_verify "$url" "$file" "$checksum" download_and_verify "$url" "$file" "$checksum" || status=$? done return $status } stats() { Loading @@ -88,7 +95,7 @@ stats() { for url in "${packages[@]}"; do checksum="${url#*#}" if test_mirrored "$checksum"; then confirmed="$((confirmed + 1))" : $((confirmed++)) else echo "failed: $url" >&2 fi Loading
script/test +2 −10 Original line number Diff line number Diff line #!/usr/bin/env bash #!/bin/bash set -e set -x STATUS=0 bats ${CI:+--tap} test || STATUS="$?" if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then ./script/mirror verify "$COMMIT_RANGE" fi exit "$STATUS" bats ${CI:+--tap} test