Skip to content
This repository has been archived by the owner on Mar 2, 2024. It is now read-only.

docs: Un-license UISlot code #859

docs: Un-license UISlot code

docs: Un-license UISlot code #859

Workflow file for this run

name: CI Workflow
# Note: we want to split this huge workflow up into smaller ones (validate, build, deploy)
# But until it's possible to reference workflows that use the same commit
# (see https://stackoverflow.com/questions/69532525/workflow )
# We just have to use this one giant workflow.
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
# deno-version: ">=1.26.0 <1.27.0" - no longer using this format for version spec, because often the docker images are published days after the release, causing a build error
deno-version: "1.34.x"
docker-registry: ghcr.io
jobs:
######################################################################################################################
## Validate
######################################################################################################################
lint:
runs-on: ubuntu-latest
steps:
- name: Setup repo
uses: actions/checkout@v3
- name: Setup Deno
uses: denoland/[email protected]
with:
deno-version: ${{ env.deno-version }}
- name: Verify formatting (backend)
run: deno fmt --check
working-directory: ./backend
- name: Run linter (backend)
run: deno lint
working-directory: ./backend
- name: Run linter (API)
run: deno lint src
working-directory: ./neolace-sdk
# - name: Run linter (frontend)
# run: npm run lint
# working-directory: ./frontend
check-backend-types:
runs-on: ubuntu-latest
steps:
- name: Setup repo
uses: actions/checkout@v3
- name: Setup Deno
uses: denoland/[email protected]
with:
deno-version: ${{ env.deno-version }}
- name: Type check backend
# Note: we don't want to use --no-lock, but esm.sh is serving some flaky lodash modules (for Chevrotain) with
# different hashes, so we have to disable it for now :/
run: deno check neolace/rest-api/server.ts --no-lock
working-directory: ./backend
# Type checking the test suite is a bit slow so we do it asynchronously now too, while the actual tests themselves run in a separate job
- name: Type check test suite setup
run: deno check neolace/scripts/test-setup.ts --no-lock
working-directory: ./backend
- name: Type check tests
env:
ENV_TYPE: test
run: deno test --check --no-run --no-lock
working-directory: ./backend
test-backend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Deno
uses: denoland/[email protected]
with:
deno-version: ${{ env.deno-version }}
- name: Run neolace database servers
run: docker-compose -f "docker-compose.yml" up -d
- name: Wait for Neo4j
run: sleep 10
- name: Test Suite setup (backend)
env:
ENV_TYPE: test
# Note: we don't want --no-lock here, but esm.sh is serving some flaky lodash modules (for Chevrotain) with
# different hashes, so we have to disable it for now :/
run: deno run --allow-net --allow-read --allow-env --allow-write --no-lock neolace/scripts/test-setup.ts
working-directory: ./backend
- name: Run tests (backend)
env:
ENV_TYPE: test
run: deno test --allow-net --allow-env --allow-read --no-check --no-lock
working-directory: ./backend
timeout-minutes: 15
- name: Stop containers
if: always()
run: docker-compose -f "docker-compose.yml" down
test-api-and-frontend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Deno
uses: denoland/[email protected]
with:
deno-version: ${{ env.deno-version }}
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Run tests (neolace-sdk)
run: deno test
working-directory: ./neolace-sdk
- name: Compile neolace-sdk
run: ./_compile.ts
working-directory: ./neolace-sdk
- run: npm ci
working-directory: ./frontend
- name: Run tests (frontend)
run: ./node_modules/.bin/jest test
working-directory: ./frontend
######################################################################################################################
## Build & Publish Docker Images
######################################################################################################################
build-and-push-images:
runs-on: ubuntu-latest
needs: [lint, check-backend-types, test-backend, test-api-and-frontend]
strategy:
matrix:
include:
- component: backend
title: Neolace Backend
- component: frontend
title: Neolace Frontend
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
# Detect deno version using the same mechanism as the other Deno jobs in this file (e.g. "v1.16.x" becomes "1.16.4")
- name: Detect which Deno version to use
id: deno-version
uses: denoland/[email protected]
with:
deno-version: ${{ env.deno-version }}
- name: Log in to the Container registry
uses: docker/[email protected]
with:
registry: ${{ env.docker-registry }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Add SHORT_SHA env property with commit short sha since GitHub doesn't provide it
run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV
- name: Get branch name since GitHub doesn't provide it
id: branch-name
uses: tj-actions/branch-names@7f0a69aa8e80f46987e8979c73ac9923d6a3c004
- name: Determine tag to use
uses: haya14busa/[email protected]
id: tag-condition
with:
# Are we running on main (the default branch) or a PR that will merge into main?
cond: ${{ steps.branch-name.outputs.is_default == 'true' }}
# On main, we tag with a release name like "build14-abcd678" as well as "latest"
if_true: ghcr.io/neolace-dev/neolace-${{ matrix.component }}:build${{ github.run_number }}-${{ env.SHORT_SHA }},ghcr.io/neolace-dev/neolace-${{ matrix.component }}:latest
# For merge requests, just use the branch name as the image tag; we don't want to pollute the container
# registry with too many random branch builds.
if_false: ghcr.io/neolace-dev/neolace-${{ matrix.component }}:${{ steps.branch-name.outputs.current_branch }}
- name: Build ${{ matrix.component }} Docker image
uses: docker/[email protected]
with:
file: ${{ matrix.component }}/Dockerfile
context: .
push: false
tags: ${{ steps.tag-condition.outputs.value }}
build-args:
DENO_IMAGE_VERSION=alpine-${{ steps.deno-version.outputs.deno-version }}
labels: |
org.opencontainers.image.title=${{ matrix.title }}
org.opencontainers.image.description=${{ matrix.title }}
org.opencontainers.image.url=https://www.neolace.com
org.opencontainers.image.source=https://github.com/neolace-dev/neolace-app
org.opencontainers.image.revision=${{ github.sha }}
- name: Push ${{ matrix.component }} Docker image
# For now we are only pushing if this is built on main, but we always build to test that the build works.
if: github.ref == 'refs/heads/main'
uses: docker/[email protected]
with:
file: ${{ matrix.component }}/Dockerfile
context: .
push: true
tags: ${{ steps.tag-condition.outputs.value }}
build-args:
DENO_IMAGE_VERSION=alpine-${{ steps.deno-version.outputs.deno-version }}
labels: |
org.opencontainers.image.title=${{ matrix.title }}
org.opencontainers.image.description=${{ matrix.title }}
org.opencontainers.image.url=https://www.neolace.com
org.opencontainers.image.source=https://github.com/neolace-dev/neolace-app
org.opencontainers.image.revision=${{ github.sha }}
# It will now be available at:
# https://github.com/neolace-dev/neolace-app/pkgs/container/neolace-backend
# https://github.com/neolace-dev/neolace-app/pkgs/container/neolace-frontend
######################################################################################################################
## Deploy Docker Images
######################################################################################################################