ci: hermetic tests on every push, and a skew job against a released hub
A client that only ever meets the hub it was written with is not tested against the hubs operators run. The skew job downloads a released binary and runs the same suite against it. It needs CHAIN_RELEASE_READ_TOKEN, because a Forgejo job token cannot read release assets, and says so and fails instead of passing quietly when the secret is absent. Signed-off-by: flemming-it <sf@flemming.it>
This commit is contained in:
parent
0db793494d
commit
986377f1df
2 changed files with 107 additions and 0 deletions
99
.forgejo/workflows/ci.yml
Normal file
99
.forgejo/workflows/ci.yml
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
hermetic:
|
||||
name: Type-check and hermetic tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
# actions/checkout clones via the runner's internal forgejo URL,
|
||||
# which the job container cannot resolve. Same workaround as the
|
||||
# platform repo.
|
||||
- name: Checkout via external URL
|
||||
run: |
|
||||
set -eu
|
||||
mkdir -p "$GITHUB_WORKSPACE"
|
||||
cd "$GITHUB_WORKSPACE"
|
||||
git init -q
|
||||
git remote add origin \
|
||||
"https://x-access-token:${GITHUB_TOKEN}@git.flemming.ai/${GITHUB_REPOSITORY}.git"
|
||||
git fetch --depth=1 origin "$GITHUB_SHA"
|
||||
git checkout -q FETCH_HEAD
|
||||
|
||||
- name: Install Node
|
||||
run: |
|
||||
apt-get update -qq
|
||||
apt-get install -y --no-install-recommends curl ca-certificates
|
||||
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
|
||||
apt-get install -y --no-install-recommends nodejs
|
||||
node --version
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci --ignore-scripts || npm install --ignore-scripts
|
||||
|
||||
- name: Type-check
|
||||
run: npm run check
|
||||
|
||||
- name: Hermetic tests (client against the fake hub)
|
||||
run: npm test
|
||||
|
||||
skew:
|
||||
name: Skew — this client against a released hub
|
||||
runs-on: ubuntu-latest
|
||||
# The client has to keep working against the hub operators
|
||||
# actually run, not only against the one it was written with.
|
||||
# Needs a token that may read release assets; without it the job
|
||||
# reports that rather than passing quietly.
|
||||
steps:
|
||||
- name: Checkout via external URL
|
||||
run: |
|
||||
set -eu
|
||||
mkdir -p "$GITHUB_WORKSPACE"
|
||||
cd "$GITHUB_WORKSPACE"
|
||||
git init -q
|
||||
git remote add origin \
|
||||
"https://x-access-token:${GITHUB_TOKEN}@git.flemming.ai/${GITHUB_REPOSITORY}.git"
|
||||
git fetch --depth=1 origin "$GITHUB_SHA"
|
||||
git checkout -q FETCH_HEAD
|
||||
|
||||
- name: Check for the release read token
|
||||
env:
|
||||
CHAIN_RELEASE_READ_TOKEN: ${{ secrets.CHAIN_RELEASE_READ_TOKEN }}
|
||||
run: |
|
||||
if [ -z "${CHAIN_RELEASE_READ_TOKEN:-}" ]; then
|
||||
echo "CHAIN_RELEASE_READ_TOKEN is not set in this repository."
|
||||
echo "The skew job needs it to download a released chain binary;"
|
||||
echo "a Forgejo job token cannot read release assets."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Install Node
|
||||
run: |
|
||||
apt-get update -qq
|
||||
apt-get install -y --no-install-recommends curl ca-certificates
|
||||
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
|
||||
apt-get install -y --no-install-recommends nodejs
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci --ignore-scripts || npm install --ignore-scripts
|
||||
|
||||
- name: Download the released hub
|
||||
env:
|
||||
CHAIN_RELEASE_READ_TOKEN: ${{ secrets.CHAIN_RELEASE_READ_TOKEN }}
|
||||
run: |
|
||||
set -eu
|
||||
curl -fsSL -H "Authorization: token ${CHAIN_RELEASE_READ_TOKEN}" \
|
||||
-o chain-linux-x86_64 \
|
||||
"https://releases.chain.flemming.ai/latest/chain-linux-x86_64"
|
||||
chmod +x chain-linux-x86_64
|
||||
./chain-linux-x86_64 --version
|
||||
|
||||
- name: Run the client against it
|
||||
env:
|
||||
CHAIN_BIN: ${{ github.workspace }}/chain-linux-x86_64
|
||||
run: npm test
|
||||
Loading…
Add table
Add a link
Reference in a new issue