CI: Split frontend tests from SDK workflow #955
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release SDK & UI | |
env: | |
CI: true | |
FORCE_COLOR: true | |
on: | |
push: | |
paths-ignore: | |
- 'docs/**' | |
- 'packages/contracts/**' | |
- 'README.md' | |
- 'LICENSE' | |
- 'papers/**' | |
- 'images/**' | |
pull_request: | |
paths-ignore: | |
- 'docs/**' | |
- 'packages/contracts/**' | |
- 'README.md' | |
- 'LICENSE' | |
- 'papers/**' | |
- 'images/**' | |
jobs: | |
workflow-setup: | |
name: Initialize Workflow | |
runs-on: ubuntu-latest | |
# This condition checks if the pull request is not a draft | |
if: github.event.pull_request.draft == false | |
outputs: | |
publish: ${{ steps.build-flags.outputs.publish }} | |
steps: | |
- name: Set builds flags | |
id: build-flags | |
run: | | |
if [[ ${{github.event.repository.full_name}} == 'kumodao/kumo-protocol' && ${{github.event_name}} == 'push' && ( "${{github.base_ref}}" == 'main' || "${{github.ref}}" == 'refs/heads/main' ) ]]; then | |
echo "{publish}={true}" >> $GITHUB_OUTPUT | |
else | |
echo "{publish}={false}" >> $GITHUB_OUTPUT | |
fi | |
test: | |
name: Run SDK | |
runs-on: ubuntu-latest | |
needs: workflow-setup | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v3 | |
env: | |
FORCE_COLOR: 0 | |
with: | |
node-version: 18.17.1 | |
cache: 'yarn' | |
- name: Run SDK tests | |
run: | | |
yarn test:lib-base & | |
yarn test:lib-ethers | |
# - name: Test SDK integration against live contracts | |
# if: ${{ github.ref == 'refs/heads/main' }} | |
# run: yarn test-live | |
release: | |
name: Publish SDK to NPM and build Frontend image | |
if: needs.workflow-setup.outputs.publish == 'true' | |
runs-on: ubuntu-latest | |
needs: [ workflow-setup, test ] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v3 | |
env: | |
FORCE_COLOR: 0 | |
with: | |
node-version: 18.17.1 | |
cache: 'yarn' | |
- run: yarn install --frozen-lockfile | |
- run: yarn build | |
- name: Release SDK on NPM | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
run: yarn release | |
- name: Convert the GitHub repository name to lowercase | |
id: repository-name | |
uses: ASzc/change-string-case-action@v1 | |
with: | |
string: ${{ github.repository }} | |
- name: Prepare image labels and tags | |
if: ${{ github.event_name != 'pull_request' }} | |
id: prep | |
shell: bash | |
run: | | |
DOCKER_IMAGE=ghcr.io/${{ steps.repository-name.outputs.lowercase }}/dev-frontend | |
TAGS="${DOCKER_IMAGE}:latest,${DOCKER_IMAGE}:latest" | |
echo ::set-output name=tags::${TAGS} | |
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ') | |
- name: Log into the GitHub Container Registry | |
if: ${{ github.event_name != 'pull_request' }} | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
if: ${{ github.event_name != 'pull_request' }} | |
uses: docker/setup-buildx-action@v1 | |
- name: Build and push image | |
if: ${{ github.event_name != 'pull_request' }} | |
uses: docker/build-push-action@v2 | |
with: | |
context: ./packages/dev-frontend | |
no-cache: true | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.prep.outputs.tags }} | |
labels: | | |
org.opencontainers.image.source=${{ github.event.repository.html_url }} | |
org.opencontainers.image.created=${{ steps.prep.outputs.created }} | |
org.opencontainers.image.revision=${{ github.sha }} |