Runner was failing to connect to internal 'server:3000' hostname. Now uses public https://gitea.thefetagroup.com URL directly.
105 lines
3.0 KiB
YAML
105 lines
3.0 KiB
YAML
name: CI/CD Pipeline
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
tags:
|
|
- 'v*'
|
|
|
|
env:
|
|
REGISTRY: gitea.thefetagroup.com
|
|
IMAGE_NAME: bnair/cryptobot
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
run: |
|
|
git clone --depth 1 https://gitea.thefetagroup.com/bnair/CryptoTrading.git .
|
|
git fetch origin ${{ github.sha }} --depth 1
|
|
git checkout ${{ github.sha }}
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.12'
|
|
|
|
- name: Install system dependencies
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y --no-install-recommends build-essential wget
|
|
wget -q http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz
|
|
tar -xzf ta-lib-0.4.0-src.tar.gz
|
|
cd ta-lib && ./configure --prefix=/usr && sudo make && sudo make install
|
|
cd .. && rm -rf ta-lib ta-lib-0.4.0-src.tar.gz
|
|
|
|
- name: Install Python dependencies
|
|
run: |
|
|
pip install --upgrade pip
|
|
pip install -e ".[dev]"
|
|
|
|
- name: Run linting
|
|
run: ruff check .
|
|
|
|
- name: Run format check
|
|
run: ruff format --check .
|
|
|
|
- name: Run type checking
|
|
run: mypy src/
|
|
|
|
- name: Run tests
|
|
run: pytest --cov=tradefinder --cov-report=term-missing
|
|
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
needs: test
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
steps:
|
|
- name: Checkout code
|
|
run: |
|
|
git clone --depth 1 https://gitea.thefetagroup.com/bnair/CryptoTrading.git .
|
|
git fetch origin ${{ github.ref_name }} --depth 1
|
|
git checkout ${{ github.ref_name }}
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Extract version from tag
|
|
id: version
|
|
run: echo "VERSION=${{ github.ref_name }}" >> $GITHUB_OUTPUT
|
|
|
|
- name: Login to Gitea Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
|
|
|
- name: Build and push engine image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile
|
|
target: engine
|
|
push: true
|
|
tags: |
|
|
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.VERSION }}
|
|
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
- name: Build and push UI image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile
|
|
target: ui
|
|
push: true
|
|
tags: |
|
|
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-ui:${{ steps.version.outputs.VERSION }}
|
|
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-ui:latest
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|