69 lines
3.3 KiB
YAML
69 lines
3.3 KiB
YAML
name: ci
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
test-and-build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Check out fixed Frontend and UI commits
|
|
env:
|
|
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
UI_DEPLOY_KEY: ${{ secrets.UI_DEPLOY_KEY }}
|
|
UI_SHA: 7c35a78abc8ef7db6fb2d508b2971d59a90de964
|
|
run: |
|
|
set -euo pipefail
|
|
printf 'context server=%s repository=%s sha=%s\n' "${GITHUB_SERVER_URL}" "${GITHUB_REPOSITORY}" "${GITHUB_SHA}"
|
|
[[ "${GITHUB_SERVER_URL}" =~ ^https?://[^/]+/?$ ]]
|
|
test "${GITHUB_REPOSITORY}" = "weichen/Agent-System-Frontend"
|
|
[[ "${GITHUB_SHA}" =~ ^[0-9a-f]{40}$ ]]
|
|
[[ "${UI_SHA}" =~ ^[0-9a-f]{40}$ ]]
|
|
test -n "${TOKEN}"
|
|
if [ -z "${UI_DEPLOY_KEY}" ]; then
|
|
echo "UI_DEPLOY_KEY is required for the private UI dependency" >&2
|
|
exit 1
|
|
fi
|
|
export GIT_TERMINAL_PROMPT=0
|
|
mkdir -p "${RUNNER_TEMP}/iam-frontend-ci/frontend" "${RUNNER_TEMP}/iam-frontend-ci/ui"
|
|
cd "${RUNNER_TEMP}/iam-frontend-ci/frontend"
|
|
git init -q
|
|
git remote add origin "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git"
|
|
git -c http.extraheader="AUTHORIZATION: token ${TOKEN}" fetch --depth=1 origin "${GITHUB_SHA}"
|
|
git checkout -q --detach FETCH_HEAD
|
|
test "$(git rev-parse HEAD)" = "${GITHUB_SHA}"
|
|
umask 077
|
|
trap 'rm -f "${RUNNER_TEMP}/iam-frontend-ci/ui_deploy_key" "${RUNNER_TEMP}/iam-frontend-ci/ui_known_hosts"' EXIT
|
|
printf '%s' "${UI_DEPLOY_KEY}" > "${RUNNER_TEMP}/iam-frontend-ci/ui_deploy_key"
|
|
printf '%s\n' '[git-ssh.u1680832.nyat.app]:31411 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK55QSxDqMMZ1HIWHSPkQ7fyJkDKbdg98TeIv6SrR3qx' > "${RUNNER_TEMP}/iam-frontend-ci/ui_known_hosts"
|
|
export GIT_SSH_COMMAND="ssh -F /dev/null -i ${RUNNER_TEMP}/iam-frontend-ci/ui_deploy_key -o IdentitiesOnly=yes -o StrictHostKeyChecking=yes -o UserKnownHostsFile=${RUNNER_TEMP}/iam-frontend-ci/ui_known_hosts -p 31411"
|
|
cd "${RUNNER_TEMP}/iam-frontend-ci/ui"
|
|
git init -q
|
|
git remote add origin "ssh://git@git-ssh.u1680832.nyat.app:31411/weichen/Agent-System-UI.git"
|
|
git fetch --depth=1 origin "${UI_SHA}"
|
|
git checkout -q --detach FETCH_HEAD
|
|
test "$(git rev-parse HEAD)" = "${UI_SHA}"
|
|
git -C "${RUNNER_TEMP}/iam-frontend-ci/frontend" status --short
|
|
git -C "${RUNNER_TEMP}/iam-frontend-ci/ui" status --short
|
|
- name: Install Node 22
|
|
env:
|
|
NODE_ARCHIVE_SHA256: df450af89261115ef9f9e3830c3eeb2cc9213b63c720b1af623cb5dcbe2e02de
|
|
run: |
|
|
set -euo pipefail
|
|
curl -fsSL -o "$RUNNER_TEMP/node.tar.xz" https://npmmirror.com/mirrors/node/v22.23.3/node-v22.23.3-linux-x64.tar.xz
|
|
printf '%s %s\n' "${NODE_ARCHIVE_SHA256}" "$RUNNER_TEMP/node.tar.xz" | sha256sum -c -
|
|
tar -C /usr/local --strip-components=1 -xJf "$RUNNER_TEMP/node.tar.xz"
|
|
- name: Install dependencies
|
|
run: |
|
|
set -euo pipefail
|
|
npm ci --prefix "${RUNNER_TEMP}/iam-frontend-ci/ui"
|
|
npm ci --prefix "${RUNNER_TEMP}/iam-frontend-ci/frontend"
|
|
- name: Test and build
|
|
run: |
|
|
set -euo pipefail
|
|
cd "${RUNNER_TEMP}/iam-frontend-ci/frontend"
|
|
npm test
|
|
npm run build
|