Skip to content

Merge pull request #36 from TailUFPB/develop #106

Merge pull request #36 from TailUFPB/develop

Merge pull request #36 from TailUFPB/develop #106

Workflow file for this run

name: CI
# Controls when the workflow will run
on:
push:
branches: ["main"]
# Prevent duplicate workflows from running
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# Static tests don't involve any logic or context.
# They are just a set of tests that can detect if we are not introducing any faulty code.
static-test:
name: πŸ”¬ Static tests
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: βŽ” Setup Node
uses: actions/setup-node@v3
with:
cache: "npm"
- name: 🟨 Setup Python
uses: actions/setup-python@v3
- name: πŸ“¦ Install Node dependencies
run: npm install
# # Unit tests are tests that are not dependent on any external service.
# # Usually, they are tests that are testing the logic of a specific function or component.
unit-test:
needs: [static-test]
name: 🚦 Unit tests
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: βŽ” Setup Node
uses: actions/setup-node@v3
with:
cache: "npm"
- name: 🟨 Setup Python
uses: actions/setup-python@v3
- name: πŸ“¦ Install dependencies
run: npm install
- name: 🚦 Run unit tests
run: npm test
# # Integration tests are tests that are dependent on external services.
integration-test:
needs: [static-test]
name: πŸš₯ Integration tests
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: βŽ” Setup Node
uses: actions/setup-node@v3
with:
cache: "npm"
- name: 🟨 Setup Python
uses: actions/setup-python@v3
- name: πŸ“¦ Install dependencies
run: npm install
# - name: 🐳 Docker compose
# run:
# docker-compose up -d && sleep 3 && pnpm prisma migrate reset --force
# --skip-seed
- name: 🚦 Run integration tests
run: npm test
# Create Build
build:
needs: [static-test, unit-test, integration-test]
name: πŸ—οΈ Build
runs-on: windows-latest
strategy:
fail-fast: false
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Set up conda
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: default
environment-file: api/environment.yml
- name: ⬇️ Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: βŽ” Setup Node
uses: actions/setup-node@v3
with:
cache: "npm"
- name: 🟨 Setup Python
uses: actions/setup-python@v3
with:
python-version: 3.12.3
- name: Install pip dependencies
run: pip install -r api/requirements.txt pyinstaller==6.6.0
- name: Build flask exe
run: pyinstaller api/app.spec
- name: Install dependencies
run: npm install
- name: πŸ“¦ Electron Builder
run: npm run electron:package:win
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Print directory tree
run: tree
- name: Get latest release number
id: get_latest_release
uses: actions/github-script@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const response = await github.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo,
per_page: 10
});
const latestPreRelease = response.data[0];
const preReleaseTag = latestPreRelease.name;
const versionParts = preReleaseTag.replace(/^v/, '').split('.');
const newVersion = `${parseInt(versionParts[0])}.${parseInt(versionParts[1])+1}.0`;
console.log(`::set-output name=new_version::${newVersion}`);
- name: Rename file
run: ren "dist\LinguifAI Setup 0.1.0.exe" "LinguifAI Setup ${{ steps.get_latest_release.outputs.new_version }}.exe"
- name: Get latest commit message
id: get_latest_commit_message
uses: actions/github-script@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const response = await github.repos.listCommits({
owner: context.repo.owner,
repo: context.repo.repo,
per_page: 1,
});
console.log(`::set-output name=commit_message::${response.data[0].commit.message}`);
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
with:
files: |
./dist/LinguifAI\ Setup\ ${{ steps.get_latest_release.outputs.new_version }}.exe
tag_name: v${{ steps.get_latest_release.outputs.new_version }}
name: v${{ steps.get_latest_release.outputs.new_version }}
prerelease: true
body: ${{ steps.get_latest_commit_message.outputs.commit_message }}