Skip to content

Commit

Permalink
Merge pull request #4 from EndstoneMC/next
Browse files Browse the repository at this point in the history
refactor: project structure
  • Loading branch information
wu-vincent authored Jan 30, 2024
2 parents 1556f4c + eb3e719 commit 7e3d47e
Show file tree
Hide file tree
Showing 85 changed files with 196 additions and 205 deletions.
52 changes: 2 additions & 50 deletions .github/workflows/ci-linux.yml → .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -1,61 +1,13 @@
name: Endstone CI (Linux)
name: Linux

on:
push:
branches:
- next
- main
pull_request:
workflow_dispatch:

jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-20.04, ubuntu-22.04 ]
build_type: [ Debug, Release ]

name: Build on ${{ matrix.os }} (${{ matrix.build_type }})
runs-on: ${{ matrix.os }}

steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'

- name: Set up Clang 15
env:
LLVM_VERSION: 15
run: |
sudo apt-get update -y -q
sudo apt-get install -y -q lsb-release wget software-properties-common gnupg
sudo wget https://apt.llvm.org/llvm.sh
sudo chmod +x llvm.sh
sudo ./llvm.sh ${LLVM_VERSION}
sudo apt-get install -y -q libc++-${LLVM_VERSION}-dev libc++abi-${LLVM_VERSION}-dev
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${LLVM_VERSION} 100
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-${LLVM_VERSION} 100
sudo update-alternatives --install /usr/bin/llvm-cov llvm-cov /usr/bin/llvm-cov-${LLVM_VERSION} 100
sudo update-alternatives --install /usr/bin/ld ld /usr/bin/ld.lld-${LLVM_VERSION} 100
- name: Set up CMake and Ninja
uses: lukka/get-cmake@latest

- name: Build with Conan
run: |
python -m pip install --upgrade pip
pip install conan
conan profile detect --force
conan export third_party/funchook --version 1.1.3
conan create . --build=missing -pr:a .github/conan_profiles/linux -s build_type=${{ matrix.build_type }}
coverage:
name: Code Coverage
runs-on: ubuntu-20.04
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
name: Docker Publish
name: Docker

on:
schedule:
- cron: '0 0 * * *'
push:
branches: [ "next" ]
tags: [ 'v*.*.*' ]
branches:
- main
tags:
- '*'

jobs:
build:

runs-on: ubuntu-latest
permissions:
packages: write
Expand Down Expand Up @@ -46,7 +47,7 @@ jobs:
endstone/endstone
ghcr.io/endstonemc/endstone
tags: |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'next') }}
type=raw,value=latest,enable=${{is_default_branch}}
type=pep440,pattern={{version}}
- name: Build and Push Docker Image
Expand Down
57 changes: 57 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Linux

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-20.04, ubuntu-22.04 ]
build_type: [ Debug, Release ]

name: Build on ${{ matrix.os }} (${{ matrix.build_type }})
runs-on: ${{ matrix.os }}

steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'

- name: Set up Clang 15
env:
LLVM_VERSION: 15
run: |
sudo apt-get update -y -q
sudo apt-get install -y -q lsb-release wget software-properties-common gnupg
sudo wget https://apt.llvm.org/llvm.sh
sudo chmod +x llvm.sh
sudo ./llvm.sh ${LLVM_VERSION}
sudo apt-get install -y -q libc++-${LLVM_VERSION}-dev libc++abi-${LLVM_VERSION}-dev
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${LLVM_VERSION} 100
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-${LLVM_VERSION} 100
sudo update-alternatives --install /usr/bin/llvm-cov llvm-cov /usr/bin/llvm-cov-${LLVM_VERSION} 100
sudo update-alternatives --install /usr/bin/ld ld /usr/bin/ld.lld-${LLVM_VERSION} 100
- name: Set up CMake and Ninja
uses: lukka/get-cmake@latest

- name: Build with Conan
run: |
python -m pip install --upgrade pip
pip install conan
conan profile detect --force
conan export third_party/funchook --version 1.1.3
conan create . --build=missing -pr:a .github/conan_profiles/linux -s build_type=${{ matrix.build_type }}
38 changes: 19 additions & 19 deletions .github/workflows/cd.yml → .github/workflows/wheel.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: Endstone CD
name: Wheel

on:
push:
branches:
- next
- main
tags:
- '*'
workflow_dispatch:

jobs:
build_wheels_windows:
name: Build wheel for Python ${{ matrix.python }} on Windows
name: Build Wheels for Python ${{ matrix.python }} on Windows

strategy:
fail-fast: false
Expand Down Expand Up @@ -46,28 +46,28 @@ jobs:
conan export third_party/funchook --version 1.1.3
conan install . --build=missing -pr:a .github/conan_profiles/windows
- name: Build wheels
- name: Build Wheels
run: |
python -m pip install -U pip
pip install wheel
python -m pip wheel . --no-deps --wheel-dir=wheelhouse --verbose
- name: Test wheels
- name: Test Wheels
run: |
pip install pytest
Get-ChildItem ./wheelhouse/ -Filter *.whl | ForEach-Object {
pip install $_.FullName
}
pytest endstone_python/test
pytest python/tests
- name: Upload artifacts
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: artifact
path: ./wheelhouse/*.whl

build_wheels_linux:
name: Build wheel for Python ${{ matrix.python }} on Ubuntu
name: Build Wheels for Python ${{ matrix.python }} on Ubuntu

strategy:
fail-fast: false
Expand Down Expand Up @@ -113,31 +113,31 @@ jobs:
conan export third_party/funchook --version 1.1.3
conan install . --build=missing -pr:a .github/conan_profiles/linux
- name: Build wheels
- name: Build Wheels
run: |
python -m pip install -U pip
pip install wheel
python -m pip wheel . --no-deps --wheel-dir=wheelhouse --verbose
- name: Repair wheels
- name: Repair Wheels
run: |
pip install auditwheel setuptools "patchelf>=0.14"
python -m auditwheel --verbose repair --plat manylinux_2_31_x86_64 -w wheelhouse wheelhouse/*.whl
- name: Test wheels
- name: Test Wheels
run: |
pip install pytest
pip install wheelhouse/*.whl
pytest endstone_python/test
pytest python/tests
- name: Upload artifacts
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: artifact
path: ./wheelhouse/*.whl

build_sdist:
name: Build source distribution
name: Build Source Distribution
runs-on: ubuntu-latest
steps:
- name: Checkout Code
Expand All @@ -148,14 +148,14 @@ jobs:
- name: Build sdist
run: pipx run build --sdist

- name: Upload artifacts
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: artifact
path: dist/*.tar.gz

publish:
name: Publish
name: Publish Wheels to PyPI
if: contains(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
needs: [ build_wheels_windows, build_wheels_linux, build_sdist ]
Expand All @@ -165,16 +165,16 @@ jobs:
contents: write

steps:
- name: Restore artifacts
- name: Restore Artifacts
uses: actions/download-artifact@v3
with:
name: artifact
path: dist

- name: Release
- name: Create a Release
uses: softprops/action-gh-release@v1
with:
files: dist/*

- name: Publish package to PyPI
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Endstone CI (Windows)
name: Windows

on:
push:
branches:
- next
- main
pull_request:
workflow_dispatch:

Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ _deps
.idea/*
build/*
bedrock_server/*
wheelhouse/*
wheelhouse/*
Loading

0 comments on commit 7e3d47e

Please sign in to comment.