mirror of
https://github.com/rbenv/ruby-build.git
synced 2025-01-01 14:44:48 +01:00
Update ruby-build download mirror in GitHub Actions
This commit is contained in:
parent
45b3f7f7e2
commit
7f368a7592
4 changed files with 40 additions and 18 deletions
11
.github/workflows/ci.yml
vendored
11
.github/workflows/ci.yml
vendored
|
@ -13,7 +13,12 @@ jobs:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- run: git clone --depth 1 https://github.com/sstephenson/bats.git
|
- name: Install bats
|
||||||
- run: PATH="./bats/bin:$PATH" script/test
|
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:
|
env:
|
||||||
COMMIT_RANGE: ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}
|
COMMIT_RANGE: ${{ github.event.pull_request.base.sha }}..
|
||||||
|
|
18
.github/workflows/mirror.yml
vendored
Normal file
18
.github/workflows/mirror.yml
vendored
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
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 }}
|
|
@ -53,31 +53,38 @@ update() {
|
||||||
local url
|
local url
|
||||||
local checksum
|
local checksum
|
||||||
local file
|
local file
|
||||||
|
local tmp_path
|
||||||
for url in $(potentially_new_packages "$1"); do
|
for url in $(potentially_new_packages "$1"); do
|
||||||
checksum="${url#*#}"
|
checksum="${url#*#}"
|
||||||
url="${url%#*}"
|
url="${url%#*}"
|
||||||
if test_mirrored "$checksum"; then
|
if test_mirrored "$checksum"; then
|
||||||
echo "Already mirrored: $url"
|
echo "Already mirrored: $url"
|
||||||
else
|
else
|
||||||
echo "Mirroring: $url"
|
echo "Will mirror: $url"
|
||||||
file="${TMPDIR:-/tmp}/$checksum"
|
[ -n "$tmp_path" ] || tmp_path="$(mktemp -d "${TMPDIR:-/tmp}/s3-sync.XXXXX")"
|
||||||
|
file="$tmp_path/$checksum"
|
||||||
download_and_verify "$url" "$file" "$checksum"
|
download_and_verify "$url" "$file" "$checksum"
|
||||||
./script/s3-put "$file" "${AMAZON_S3_BUCKET?}"
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
if [ -n "$tmp_path" ]; then
|
||||||
|
echo "Uploading..."
|
||||||
|
aws s3 sync --acl=public-read --size-only "$tmp_path" "s3://${AMAZON_S3_BUCKET?}"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
verify() {
|
verify() {
|
||||||
local url
|
local url
|
||||||
local checksum
|
local checksum
|
||||||
local file
|
local file
|
||||||
|
local status=0
|
||||||
for url in $(potentially_new_packages "$1"); do
|
for url in $(potentially_new_packages "$1"); do
|
||||||
checksum="${url#*#}"
|
checksum="${url#*#}"
|
||||||
url="${url%#*}"
|
url="${url%#*}"
|
||||||
echo "Verifying checksum for $url"
|
echo "Verifying checksum for $url"
|
||||||
file="${TMPDIR:-/tmp}/$checksum"
|
file="${TMPDIR:-/tmp}/$checksum"
|
||||||
download_and_verify "$url" "$file" "$checksum"
|
download_and_verify "$url" "$file" "$checksum" || status=$?
|
||||||
done
|
done
|
||||||
|
return $status
|
||||||
}
|
}
|
||||||
|
|
||||||
stats() {
|
stats() {
|
||||||
|
@ -88,7 +95,7 @@ stats() {
|
||||||
for url in "${packages[@]}"; do
|
for url in "${packages[@]}"; do
|
||||||
checksum="${url#*#}"
|
checksum="${url#*#}"
|
||||||
if test_mirrored "$checksum"; then
|
if test_mirrored "$checksum"; then
|
||||||
confirmed="$((confirmed + 1))"
|
: $((confirmed++))
|
||||||
else
|
else
|
||||||
echo "failed: $url" >&2
|
echo "failed: $url" >&2
|
||||||
fi
|
fi
|
||||||
|
|
12
script/test
12
script/test
|
@ -1,12 +1,4 @@
|
||||||
#!/usr/bin/env bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
set -x
|
|
||||||
|
|
||||||
STATUS=0
|
bats ${CI:+--tap} test
|
||||||
bats ${CI:+--tap} test || STATUS="$?"
|
|
||||||
|
|
||||||
if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then
|
|
||||||
./script/mirror verify "$COMMIT_RANGE"
|
|
||||||
fi
|
|
||||||
|
|
||||||
exit "$STATUS"
|
|
||||||
|
|
Loading…
Reference in a new issue