Skip to content

Commit

Permalink
[CI] Add CircleCI Pipelines (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
HaiyiMei committed Jul 2, 2024
1 parent 9c4fc08 commit ff8c22b
Show file tree
Hide file tree
Showing 14 changed files with 582 additions and 66 deletions.
27 changes: 27 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: 2.1
setup: true
orbs:
path-filtering: circleci/[email protected]

workflows:
generate-config:
jobs:
- path-filtering/filter:
base-revision: main
config-path: .circleci/continue_config.yml
mapping: |
# -- Unreal Plugin -- #
src/XRFeitoriaUnreal/.* build-unreal-plugin true
src/XRFeitoriaUnreal/.* run-unreal-test true
# -- Blender Addon -- #
src/XRFeitoriaBpy/.* build-blender-addon true
src/XRFeitoriaBpy/.* run-blender-test true
# -- tests -- #
xrfeitoria/.* run-unreal-test true
xrfeitoria/.* run-blender-test true
tests/unreal/.* run-unreal-test true
tests/blender/.* run-blender-test true
filters:
# https://circleci.com/docs/workflows/#executing-workflows-for-a-git-tag
tags:
only: /^v\d+\.\d+\.\d+/
261 changes: 261 additions & 0 deletions .circleci/continue_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,261 @@
version: 2.1

parameters:
build-unreal-plugin:
type: boolean
default: false
build-blender-addon:
type: boolean
default: false
run-unreal-test:
type: boolean
default: false
run-blender-test:
type: boolean
default: false

jobs:
test-self-host:
machine: true
resource_class: openxrlab/xrfeitoria
steps:
- run:
name: "Check Runner Info"
shell: powershell.exe
command: echo "Hi I'm on Runners!"

unreal-windows:
machine: true
resource_class: openxrlab/xrfeitoria
steps:
- when:
condition: << pipeline.parameters.build-unreal-plugin >> || << pipeline.parameters.run-unreal-test >>
steps:
- checkout
- run:
name: "Build Plugins & Run Tests"
shell: powershell.exe
no_output_timeout: 60m
environment:
BUILD_UNREAL_PLUGIN: << pipeline.parameters.build-unreal-plugin >>
RUN_TEST: << pipeline.parameters.run-unreal-test >>
PYTHONIOENCODING: "utf-8"
command: |
echo "#### Install XRFeitoria Package ####"
conda activate xrfeitoria
python -m pip install .
mkdir src/dist -ErrorAction SilentlyContinue -Force
if ($env:BUILD_UNREAL_PLUGIN -eq 1) {
echo "#### Building Unreal Plugin ####"
python -m xrfeitoria.utils.publish_plugins build-unreal `
-u "C:/Program Files/Epic Games/UE_5.1/Engine/Binaries/Win64/UnrealEditor-Cmd.exe" `
-u "C:/Program Files/Epic Games/UE_5.2/Engine/Binaries/Win64/UnrealEditor-Cmd.exe" `
-u "C:/Program Files/Epic Games/UE_5.3/Engine/Binaries/Win64/UnrealEditor-Cmd.exe"
$env:XRFEITORIA__VERSION=$(python -c "import xrfeitoria; print(xrfeitoria.__version__)")
$env:XRFEITORIA__DIST_ROOT="$PWD/src"
}
if ($env:RUN_TEST -eq 1) {
echo "#### Running Tests ####"
python -m tests.setup_ci -u "C:/Program Files/Epic Games/UE_5.1/Engine/Binaries/Win64/UnrealEditor-Cmd.exe"
python -m tests.unreal.main
python -m tests.setup_ci -u "C:/Program Files/Epic Games/UE_5.2/Engine/Binaries/Win64/UnrealEditor-Cmd.exe"
python -m tests.unreal.main
python -m tests.setup_ci -u "C:/Program Files/Epic Games/UE_5.3/Engine/Binaries/Win64/UnrealEditor-Cmd.exe"
python -m tests.unreal.main
}
- when:
condition: << pipeline.parameters.build-unreal-plugin >>
steps:
- store_artifacts:
path: src/dist/
destination: Plugins
- persist_to_workspace:
root: .
paths:
- src/dist/

unreal-linux:
parameters:
image:
type: string
default: "ghcr.io/epicgames/unreal-engine:dev-5.3"
docker:
- image: << parameters.image >>
auth:
username: $GHCR_USERNAME
password: $GHCR_TOKEN
working_directory: ~/project
steps:
- when:
condition: << pipeline.parameters.build-unreal-plugin >> || << pipeline.parameters.run-unreal-test >>
steps:
- checkout
- run:
name: Install Miniconda, Python 3.10, and XRFeitoria
command: |
curl -sLo Miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda.sh -b -p $HOME/miniconda
echo "source $HOME/miniconda/bin/activate" >> $BASH_ENV
source $BASH_ENV
conda install -y python=3.10
python -m pip install .
- run:
name: "Build Plugins & Run Tests"
environment:
BUILD_UNREAL_PLUGIN: << pipeline.parameters.build-unreal-plugin >>
RUN_TEST: << pipeline.parameters.run-unreal-test >>
PYTHONIOENCODING: "utf-8"
command: |
mkdir -p /home/ue4/project/src/dist
if [ "$BUILD_UNREAL_PLUGIN" = "1" ]; then
echo "#### Building Unreal Plugin ####"
python -m xrfeitoria.utils.publish_plugins build-unreal -u "/home/ue4/UnrealEngine/Engine/Binaries/Linux/UnrealEditor-Cmd"
export XRFEITORIA__DIST_ROOT="/home/ue4/project/src"
export XRFEITORIA__VERSION=`python -c "import xrfeitoria; print(xrfeitoria.__version__)"`
rm -rf /home/ue4/project/src/dist/*-Source.zip # remove source zip, cuz it's uploaded in the win build
fi
if [ "$RUN_TEST" = "1" ]; then
echo "#### Running Tests ####"
# Can't run tests on non-gpu machine
echo "Skipping tests on non-gpu machine"
# python -m tests.setup_ci -u "/home/ue4/UnrealEngine/Engine/Binaries/Linux/UnrealEditor-Cmd"
# python -m tests.unreal.main
fi
- when:
condition: << pipeline.parameters.build-unreal-plugin >>
steps:
- store_artifacts:
when: << pipeline.parameters.build-unreal-plugin >>
path: src/dist/
destination: Plugins
- persist_to_workspace:
when: << pipeline.parameters.build-unreal-plugin >>
root: /home/ue4/project
paths:
- src/dist/

blender:
docker:
- image: linuxserver/blender:3.6.5
steps:
- when:
condition: << pipeline.parameters.build-blender-addon >> || << pipeline.parameters.run-blender-test >>
steps:
- checkout
- run:
name: Install Essential Packages
command: |
apt-get update
apt-get install -y git
- run:
name: Install Miniconda, Python 3.10, and XRFeitoria
command: |
curl -sLo Miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda.sh -b -p $HOME/miniconda
echo "source $HOME/miniconda/bin/activate" >> $BASH_ENV
source $BASH_ENV
conda install -y python=3.10
python -m pip install .
- run:
name: "Build Blender Addon & Run Tests"
environment:
BUILD_BLENDER_ADDON: << pipeline.parameters.build-blender-addon >>
RUN_TEST: << pipeline.parameters.run-blender-test >>
PYTHONIOENCODING: "utf-8"
command: |
if [ "$BUILD_BLENDER_ADDON" = "1" ]; then
echo "#### Building Blender Addon ####"
python -m xrfeitoria.utils.publish_plugins build-blender
export XRFEITORIA__DIST_ROOT="/config/project/src/dist/"
export XRFEITORIA__VERSION=`python -c "import xrfeitoria; print(xrfeitoria.__version__)"`
fi
if [ "$RUN_TEST" = "1" ]; then
echo "#### Running Tests ####"
python -m tests.setup_ci -b /usr/bin/blender
python -m tests.blender.main -b
fi
- when:
condition: << pipeline.parameters.build-blender-addon >>
steps:
- store_artifacts:
path: /config/project/src/dist/
- persist_to_workspace:
root: /config/project
paths:
- src/dist/

publish-github-release:
docker:
- image: cibuilds/base:latest
steps:
- checkout
- attach_workspace:
at: ./artifacts
- run:
name: "Get GitHub Release CLI"
command: |
# https://github.com/tcnksm/ghr
GHR_VERSION="v0.16.2"
GHR_URL="https://github.com/tcnksm/ghr/releases/download/${GHR_VERSION}/ghr_${GHR_VERSION}_linux_amd64.tar.gz"
wget "$GHR_URL" && \
tar xzf ghr_${GHR_VERSION}_linux_amd64.tar.gz && \
mv ghr_${GHR_VERSION}_linux_amd64/ghr /usr/bin/ghr && \
rm -r ghr_${GHR_VERSION}_linux_amd64.tar.gz ghr_${GHR_VERSION}_linux_amd64/
- run:
name: "Publish Release on GitHub"
command: |
VERSION=$(git describe --tags --abbrev=0)
RELEASE_TITLE="XRFeitoria Release $VERSION"
if [ -d "./artifacts/src/dist" ]; then
DIST_PATH="./artifacts/src/dist/"
else
DIST_PATH=""
fi
ghr \
-t ${GITHUB_TOKEN} \
-u ${CIRCLE_PROJECT_USERNAME} \
-r ${CIRCLE_PROJECT_REPONAME} \
-c ${CIRCLE_SHA1} \
-n "${RELEASE_TITLE}" \
-draft \
-generatenotes \
-delete \
${VERSION} ${DIST_PATH}
workflows:
plugin-workflow:
jobs:
# -- Unreal -- #
- test-self-host:
filters:
tags:
only: /^v\d+\.\d+\.\d+/
- unreal-windows:
requires:
- test-self-host
filters:
tags:
only: /^v\d+\.\d+\.\d+/
- unreal-linux:
matrix:
parameters:
image: ["ghcr.io/epicgames/unreal-engine:dev-5.1", "ghcr.io/epicgames/unreal-engine:dev-5.2", "ghcr.io/epicgames/unreal-engine:dev-5.3"]
filters:
tags:
only: /^v\d+\.\d+\.\d+/
# -- Blender -- #
- blender:
filters:
tags:
only: /^v\d+\.\d+\.\d+/
# -- Publish -- #
- publish-github-release:
requires:
- blender
- unreal-windows
- unreal-linux
filters:
branches:
ignore: /.*/
tags:
only: /^v\d+\.\d+\.\d+/
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ jobs:
lint:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python 3.8
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Install pre-commit hook
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
id-token: write
if: startsWith(github.event.ref, 'refs/tags')
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Python 3.8
uses: actions/setup-python@v1
uses: actions/setup-python@v5
with:
python-version: 3.8

Expand Down
Loading

0 comments on commit ff8c22b

Please sign in to comment.