mirror of
https://github.com/Canner/WrenAI.git
synced 2026-09-24 23:29:49 +08:00
[DRAFT] Chore(Wren-ui): add github action script for CI (#72)
GitHub action to release image
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
# create the github action to run the yarn lint when PR created or pushed to main branch
|
||||
#
|
||||
|
||||
name: Wren-UI Lint
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- 'wren-ui/**'
|
||||
pull_request:
|
||||
types: [ labeled ]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
# avoid mis-canceling the ci runs while other labels are added to the PR, so we add the label name as the condition
|
||||
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.label.name == 'ci/ui' && github.event.number || github.sha }}
|
||||
cancel-in-progress: true
|
||||
|
||||
defaults:
|
||||
run:
|
||||
working-directory: wren-ui
|
||||
|
||||
jobs:
|
||||
eslint:
|
||||
# run this job only if the PR is labeled with "ci/ui"
|
||||
if: ${{ github.event.label.name == 'ci/ui' || github.event_name == 'push'}}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '16'
|
||||
- name: Get yarn cache directory path
|
||||
id: yarn-cache-dir-path
|
||||
run: echo "::set-output name=dir::$(yarn cache dir)"
|
||||
- uses: actions/cache@v2
|
||||
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
|
||||
with:
|
||||
path: | # should cache node_modules as well
|
||||
${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-yarn-
|
||||
- if: ${{ steps.yarn-cache.outputs.cache-hit != 'true' }}
|
||||
name: List the state of node modules
|
||||
continue-on-error: true
|
||||
run: yarn list
|
||||
- name: Install Node.js dependencies
|
||||
run: yarn install
|
||||
- name: Run lint
|
||||
run: yarn lint
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
name: Wren-UI Release stable image
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: Give a version for this release
|
||||
type: string
|
||||
required: true
|
||||
|
||||
defaults:
|
||||
run:
|
||||
working-directory: wren-ui
|
||||
|
||||
jobs:
|
||||
build-image:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Build and push image
|
||||
run: |
|
||||
docker buildx build \
|
||||
--platform linux/amd64,linux/arm64 \
|
||||
--tag ghcr.io/canner/wren-ui:${{ github.event.inputs.version }} \
|
||||
--tag ghcr.io/canner/wren-ui:latest \
|
||||
--file ./Dockerfile \
|
||||
--push .
|
||||
@@ -0,0 +1,47 @@
|
||||
name: Wren-UI Release image
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
docker_image_tag_name:
|
||||
description: Docker image tag name (optional, default branch name/tag name replaced with hyphens)
|
||||
type: string
|
||||
|
||||
defaults:
|
||||
run:
|
||||
working-directory: wren-ui
|
||||
|
||||
jobs:
|
||||
build-image:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Prepare tag name
|
||||
id: tag-preparation
|
||||
run: |
|
||||
if [ -n "${{ github.event.inputs.docker_image_tag_name }}" ]; then
|
||||
tag_name=${{ github.event.inputs.docker_image_tag_name }}
|
||||
else
|
||||
tag_name=$(echo ${{ github.ref_name }} | sed 's/[^a-zA-Z0-9]/-/g')-$(git log -1 --pretty=%h)
|
||||
fi
|
||||
echo "TAG_NAME=$tag_name" >> $GITHUB_OUTPUT
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
- name: Build and push image
|
||||
env:
|
||||
TAG_NAME: ${{ steps.tag-preparation.outputs.TAG_NAME }}
|
||||
run: |
|
||||
echo "Building image with tag:$TAG_NAME"
|
||||
docker buildx build \
|
||||
--platform linux/amd64,linux/arm64 \
|
||||
--tag ghcr.io/canner/wren-ui:$TAG_NAME \
|
||||
--file ./Dockerfile \
|
||||
--push .
|
||||
@@ -0,0 +1,53 @@
|
||||
# create the github action to run the UI tests when PR created
|
||||
|
||||
name: Wren-UI Test
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- 'wren-ui/**'
|
||||
pull_request:
|
||||
types: [ labeled ]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
# avoid mis-canceling the ci runs while other labels are added to the PR, so we add the label name as the condition
|
||||
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.label.name == 'ci/ui' && github.event.number || github.sha }}
|
||||
cancel-in-progress: true
|
||||
|
||||
defaults:
|
||||
run:
|
||||
working-directory: wren-ui
|
||||
|
||||
jobs:
|
||||
unit-test:
|
||||
# run this job only if the PR is labeled with "ci/ui"
|
||||
if: ${{ github.event.label.name == 'ci/ui' || github.event_name == 'push'}}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '16'
|
||||
- name: Get yarn cache directory path
|
||||
id: yarn-cache-dir-path
|
||||
run: echo "::set-output name=dir::$(yarn cache dir)"
|
||||
- uses: actions/cache@v2
|
||||
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
|
||||
with:
|
||||
path: | # should cache node_modules as well
|
||||
${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-yarn-
|
||||
- if: ${{ steps.yarn-cache.cache-hit != 'true' }}
|
||||
name: List the state of node modules
|
||||
continue-on-error: true
|
||||
run: yarn list
|
||||
- name: Install dependencies
|
||||
run: yarn
|
||||
- name: Run tests
|
||||
run: yarn test
|
||||
+1
-2
@@ -8,7 +8,7 @@ WORKDIR /app
|
||||
|
||||
# Install dependencies based on the preferred package manager
|
||||
COPY package.json yarn.lock* ./
|
||||
RUN yarn --frozen-lockfile
|
||||
RUN yarn install --frozen-lockfile --network-timeout 100000
|
||||
|
||||
# Rebuild the source code only when needed
|
||||
FROM base AS builder
|
||||
@@ -19,7 +19,6 @@ COPY src ./src
|
||||
COPY .eslintrc.json ./
|
||||
COPY .eslintignore ./
|
||||
COPY .prettierrc ./
|
||||
COPY next-env.d.ts ./
|
||||
COPY next.config.js ./
|
||||
COPY tsconfig.json ./
|
||||
COPY yarn.lock ./
|
||||
|
||||
@@ -142,6 +142,7 @@ describe('MDLBuilder', () => {
|
||||
type: 'customer',
|
||||
isCalculated: false,
|
||||
relationship: 'OrderCustomer',
|
||||
properties: null,
|
||||
notNull: false,
|
||||
},
|
||||
],
|
||||
@@ -168,6 +169,7 @@ describe('MDLBuilder', () => {
|
||||
isCalculated: false,
|
||||
relationship: 'OrderCustomer',
|
||||
notNull: false,
|
||||
properties: null,
|
||||
},
|
||||
],
|
||||
primaryKey: '',
|
||||
|
||||
Reference in New Issue
Block a user