Skip to content

add tests

add tests #142

Workflow file for this run

name: package_release
on:
push:
tags:
- '*.*.*'
pull_request:
jobs:
test-package:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
py_ver:
- '3.9'
- '3.10'
- '3.11'
- '3.12'
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.py_ver }}
- name: Install Package
run: pip install .
- name: Test Package
env:
PY_VER: ${{ matrix.py_ver }}
DISCORD_BOT_TOKEN: ${{ secrets.DISCORD_BOT_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
CHANNEL_ID: ${{ secrets.CHANNEL_ID }}
USERNAME: ${{ secrets.USERNAME }}
PYTHONUNBUFFERED: 1
run: |
touch .env.test
export VERSION=$(cat discordai_modelizer/version.py | grep -oP '\d+\.\d+\.\d+')
pip install git+https://github.com/A-Baji/discordAI-modelizer.git -U
docker compose -f docker-compose-test.yaml up --build --exit-code-from tests
release:
if: |
github.event_name == 'push' &&
startsWith(github.ref, 'refs/tags') &&
github.repository_owner == 'A-Baji'
needs: test-package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- id: version
name: Get build metadata
run: echo "::set-output name=discordai_version::$(cat discordai/version.py | grep -oP '\d+\.\d+\.\d+')"
- name: Create release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.version.outputs.discordai_version }}
release_name: Release ${{ steps.version.outputs.discordai_version }}
body: Release ${{ steps.version.outputs.discordai_version }}
draft: false
prerelease: false
package:
needs: test-package
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- windows-latest
# - macos-latest
- ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install Dependencies
run: pip install . pyinstaller
# Package
- name: Windows CLI Package
if: ${{ matrix.os == 'windows-latest' }}
run: |
pyinstaller discordai/command_line/command_line.py --console --onefile --name=discordai --add-binary='discordai/bot/cogs;discordai/bot/cogs' --hidden-import=openai --collect-data=better_profanity --collect-data=discordai_modelizer
Compress-Archive -Path dist\*discordai* -DestinationPath discordai-windows.zip
- name: Mac CLI Package
if: ${{ matrix.os == 'macos-latest' }}
run: |
pyinstaller discordai/command_line/command_line.py --console --onefile --name=discordai --add-data='discordai/bot/cogs:discordai/bot/cogs' --hidden-import=openai --collect-data=better_profanity --hidden-import=configparser --collect-data=discordai_modelizer --collect-data=aiohttp --collect-data=certifi
zip -j discordai-macos.zip dist/*discordai*
chmod +x dist/*discordai*
- name: Linux CLI Package
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
pyinstaller discordai/command_line/command_line.py --console --onefile --name=discordai --add-binary='discordai/bot/cogs:discordai/bot/cogs' --hidden-import=openai --collect-data=better_profanity --collect-data=discordai_modelizer
zip -j discordai-linux.zip dist/*discordai*
chmod +x dist/*discordai*
# Upload
- name: Upload Windows Package to Artifacts
if: |
matrix.os == 'windows-latest' &&
github.event_name != 'push' &&
!startsWith(github.ref, 'refs/tags')
uses: actions/upload-artifact@v3
with:
name: discordai-windows
path: dist/*discordai*
retention-days: 1
- name: Upload Windows Package to Release
if: |
matrix.os == 'windows-latest' &&
github.event_name == 'push' &&
startsWith(github.ref, 'refs/tags') &&
github.repository_owner == 'A-Baji'
uses: softprops/action-gh-release@v1
with:
files: ./*discordai*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Mac Package to Artifacts
if: |
matrix.os == 'macos-latest' &&
github.event_name != 'push' &&
!startsWith(github.ref, 'refs/tags')
uses: actions/upload-artifact@v3
with:
name: discordai-macos
path: dist/*discordai*
retention-days: 1
- name: Upload Mac Package to Release
if: |
matrix.os == 'macos-latest' &&
github.event_name == 'push' &&
startsWith(github.ref, 'refs/tags') &&
github.repository_owner == 'A-Baji'
uses: softprops/action-gh-release@v1
with:
files: ./*discordai*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Linux Package to Artifacts
if: |
matrix.os == 'ubuntu-latest' &&
github.event_name != 'push' &&
!startsWith(github.ref, 'refs/tags')
uses: actions/upload-artifact@v3
with:
name: discordai-linux
path: dist/*discordai*
retention-days: 1
- name: Upload Linux Package to Release
if: |
matrix.os == 'ubuntu-latest' &&
github.event_name == 'push' &&
startsWith(github.ref, 'refs/tags') &&
github.repository_owner == 'A-Baji'
uses: softprops/action-gh-release@v1
with:
files: ./*discordai*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}