Skip to content

Signer Implement global error handling [sc-13127] (#210) #750

Signer Implement global error handling [sc-13127] (#210)

Signer Implement global error handling [sc-13127] (#210) #750

Workflow file for this run

name: CI
on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'examples/react-dapp/**'
- 'examples/react-signer/**'
- 'packages/identitykit/**'
- 'packages/postmessage-rpc/**'
- 'docker-for-e2e/**'
pull_request:
types:
- opened
- synchronize
env:
IMAGE_NAME: nfid-public-test
jobs:
check-formatting:
name: Check Formatting
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout repo.
uses: actions/checkout@v4
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: 20
- name: Cache Node Modules
uses: actions/cache@v4
with:
path: |
**/node_modules
**/.eslintcache
${{ steps.yarn-cache-dir-path.outputs.dir }}
key: npm
- name: Install dependencies
run: npm install --frozen-lockfile
- name: Lint
run: npm run lint:check
- name: Check Formatting
run: npm run format:check
- name: Build
run: npm run build-ci
docker-for-e2e:
name: Docker Image Build
runs-on: ubuntu-latest
needs: check-formatting
permissions:
packages: write
contents: read
steps:
- name: Checkout repo.
uses: actions/checkout@v4
- name: Log in to registry
# This is where you will update the personal access token to GITHUB_TOKEN
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
- name: Pull Build Push Image
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/${IMAGE_NAME}
# Change all uppercase to lowercase
IMAGE_ID=$(echo ${IMAGE_ID} | tr '[A-Z]' '[a-z]')
# Check is this pull request
if [ -z "${{ github.head_ref }}" ]; then
# If NOT
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
else
# If YES
# Strip git ref prefix from version and left pull-request number
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\([0-9]\+\)/\(.*\),\1-\2,')
fi
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo ${VERSION} | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "${VERSION}" == "main" ] && VERSION=latest
echo "[INFO] IMAGE_ID: ${IMAGE_ID}" >&2
echo "[INFO] VERSION : ${VERSION}" >&2
if DOCKER_CLI_EXPERIMENTAL=enabled docker manifest inspect ${IMAGE_ID}:${VERSION} >/dev/null; then
echo "[INFO] Docker image '${IMAGE_ID}:${VERSION}' was found" >&2
DOCKER_REBUILD="false"
else
echo "[WARN] Image '${IMAGE_ID}:${VERSION}' was not found" >&2
DOCKER_REBUILD="true"
fi
if git log -1 --name-only --pretty='' | grep -q docker-for-e2e; then
echo "[WARN] Files in docker-for-e2e folder was changed" >&2
DOCKER_REBUILD="true"
fi
if [ "${DOCKER_REBUILD}" == "true" ] || [ "${{ github.event.inputs.docker_rebuild }}" == "true" ]; then
echo "[WARN] Will try to build the Docker Image." >&2
pushd ./docker-for-e2e
docker build . \
--build-arg USER_ID=$(id -u) \
--build-arg GROUP_ID=$(id -g) \
--file Dockerfile \
--tag ${IMAGE_NAME} \
--label "runnumber=${GITHUB_RUN_ID}"
docker tag ${IMAGE_NAME} ${IMAGE_ID}:${VERSION}
docker push ${IMAGE_ID}:${VERSION}
fi
e2e-tests:
name: Tests
needs: docker-for-e2e
runs-on: ubuntu-latest
steps:
- name: Checkout repo.
uses: actions/checkout@v4
- name: Log in to registry
# This is where you will update the personal access token to GITHUB_TOKEN
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
- name: Pull Image and preparing Env Vars
id: pull_image
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/${IMAGE_NAME}
# Change all uppercase to lowercase
IMAGE_ID=$(echo ${IMAGE_ID} | tr '[A-Z]' '[a-z]')
# Check is this pull request
if [ -z "${{ github.head_ref }}" ]; then
# If NOT
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
else
# If YES
# Strip git ref prefix from version and left pull-request number
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\([0-9]\+\)/\(.*\),\1-\2,')
fi
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo ${VERSION} | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "${VERSION}" == "main" ] && VERSION=latest
echo "[INFO] IMAGE_ID: ${IMAGE_ID}" >&2
echo "[INFO] VERSION : ${VERSION}" >&2
docker pull ${IMAGE_ID}:${VERSION}
TEST_ADD_PARAMS=""
echo "IMAGE_ID=${IMAGE_ID}" >> $GITHUB_ENV
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "CI_DEBUG=${CI_DEBUG}" >> $GITHUB_ENV
echo "TEST_ADD_PARAMS="${TEST_ADD_PARAMS}"" >> $GITHUB_ENV
- name: Cache Node Modules
uses: actions/cache@v4
with:
path: |
**/node_modules
**/.eslintcache
${{ steps.yarn-cache-dir-path.outputs.dir }}
key: npm
- name: Run tests
env:
CI_DEBUG: true
run: |
docker run --rm \
-v $(pwd):/home/user/workdir \
-e CI_DEBUG="${CI_DEBUG}" \
${IMAGE_ID}:${VERSION} \
"${TEST_ADD_PARAMS}"