generated from mononoki/pyproj
Initial commit
This commit is contained in:
107
.gitea/workflows/build.yml
Normal file
107
.gitea/workflows/build.yml
Normal file
@@ -0,0 +1,107 @@
|
||||
name: Build image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- deploy
|
||||
tags:
|
||||
- v*.*.*
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: docker-amd64
|
||||
|
||||
env:
|
||||
REGISTRY: git.arconlab.ru
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Arch checkout
|
||||
run: test -f Dockerfile || { echo "Dockerfile not found"; exit 1; }
|
||||
|
||||
- name: Login to registry
|
||||
run: |
|
||||
echo "${{ secrets.REGISTRY_TOKEN }}" \
|
||||
| docker login "$REGISTRY" \
|
||||
-u "${{ secrets.REGISTRY_USER }}" \
|
||||
--password-stdin
|
||||
|
||||
- name: Set Version
|
||||
id: version
|
||||
run: |
|
||||
REPO=$(echo "${{ gitea.repository }}" | tr '[:upper:]' '[:lower:]')
|
||||
REF_NAME="${{ gitea.ref_name }}"
|
||||
REF_TYPE="${{ gitea.ref_type }}" # "branch" или "tag"
|
||||
|
||||
if [ "$REF_TYPE" = "tag" ]; then
|
||||
VERSION="$REF_NAME"
|
||||
else
|
||||
VERSION="${REF_NAME}_latest"
|
||||
fi
|
||||
|
||||
echo "REPO=$REPO" >> $GITHUB_ENV
|
||||
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
||||
echo "REF_TYPE=$REF_TYPE" >> $GITHUB_ENV
|
||||
|
||||
- name: Verify release tag belongs to main
|
||||
if: gitea.ref_type == 'tag'
|
||||
run: |
|
||||
|
||||
git fetch --unshallow origin \
|
||||
main:refs/remotes/origin/main \
|
||||
|| git fetch origin \
|
||||
main:refs/remotes/origin/main
|
||||
|
||||
|
||||
if ! git merge-base \
|
||||
--is-ancestor \
|
||||
"${{ gitea.sha }}" \
|
||||
origin/main
|
||||
then
|
||||
echo "ERROR: Release tags must point to a commit from main."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
- name: Set Python version
|
||||
run: |
|
||||
echo "PYTHON_VERSION=$(cat .py-version)" >> "$GITHUB_ENV"
|
||||
|
||||
|
||||
- name: Build Image
|
||||
run: |
|
||||
if [ "$REF_TYPE" = "tag" ]; then
|
||||
docker build \
|
||||
--build-arg PYTHON_VERSION="$PYTHON_VERSION" \
|
||||
--pull --no-cache --provenance=false --sbom=false \
|
||||
-t $REGISTRY/$REPO:$VERSION \
|
||||
-t $REGISTRY/$REPO:latest \
|
||||
.
|
||||
else
|
||||
docker build \
|
||||
--build-arg PYTHON_VERSION="$PYTHON_VERSION" \
|
||||
--pull --no-cache --provenance=false --sbom=false \
|
||||
-t $REGISTRY/$REPO:$VERSION \
|
||||
.
|
||||
fi
|
||||
|
||||
- name: Push Image
|
||||
run: |
|
||||
docker push $REGISTRY/$REPO:$VERSION
|
||||
if [ "$REF_TYPE" = "tag" ]; then
|
||||
docker push $REGISTRY/$REPO:latest
|
||||
fi
|
||||
|
||||
|
||||
|
||||
- name: Notify success
|
||||
if: success()
|
||||
run: |
|
||||
MESSAGE="Built image: \`${{ env.REGISTRY }}/${{ env.REPO }}:${{ env.VERSION }}\`\nBranch: \`${{ gitea.ref_name }}\`\nCommit: \`${{ gitea.sha }}\`"
|
||||
|
||||
- name: Logout
|
||||
if: always()
|
||||
run: |
|
||||
docker logout "$REGISTRY"
|
||||
50
.gitea/workflows/test.yml
Normal file
50
.gitea/workflows/test.yml
Normal file
@@ -0,0 +1,50 @@
|
||||
name: Tests
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
pytest:
|
||||
|
||||
# Имя твоего Gitea Runner.
|
||||
# У тебя уже используется docker-amd64 в build.yml.
|
||||
runs-on: docker-amd64
|
||||
|
||||
steps:
|
||||
|
||||
# -------------------------
|
||||
# Checkout repository
|
||||
# -------------------------
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
|
||||
# -------------------------
|
||||
# Python
|
||||
# -------------------------
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version-file: ".py-version"
|
||||
|
||||
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install -r req.txt
|
||||
python -m pip install -r req-dev.txt
|
||||
|
||||
|
||||
# -------------------------
|
||||
# Tests
|
||||
# -------------------------
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
python -m pytest
|
||||
Reference in New Issue
Block a user