diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml new file mode 100644 index 0000000..0d84c71 --- /dev/null +++ b/.forgejo/workflows/ci.yml @@ -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 diff --git a/README.md b/README.md index ac28e02..ca0a906 100644 --- a/README.md +++ b/README.md @@ -134,6 +134,14 @@ tests, and the guard that the `.proto` copies still match both their recorded hashes and the platform repo. The real-hub suite skips itself when no binary is there. +`.forgejo/workflows/ci.yml` runs the same two things in CI: the +hermetic suite on every push, and a skew job that downloads a +*released* hub and runs this client against it, because a client has +to keep working against the hub operators actually run. The skew job +needs the repository secret `CHAIN_RELEASE_READ_TOKEN` (a Forgejo job +token cannot read release assets) and fails with that message rather +than passing quietly when the secret is missing. + ## License Apache 2.0. Copyright Dr. Stefan Flemming, Flemming.AI.