Skip to content

Commit

Permalink
chore(tests): setup tests through circleci
Browse files Browse the repository at this point in the history
  • Loading branch information
Whinarn committed Apr 30, 2020
1 parent 2cff118 commit e6f7925
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 8 deletions.
39 changes: 39 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
version: 2.1
executors:
unity-2019:
docker:
- image: gableroux/unity3d:2019.3.6f1
environment:
UNITY_LICENSE_CONTENT_VAR: UNITY_LICENSE_CONTENT_2019_3_6

.test-2019: &test-2019
executor: unity-2019
steps:
- checkout
- run:
name: Preparing Unity
command: chmod +x ./.circleci/scripts/prepare_unity.sh && ./.circleci/scripts/prepare_unity.sh
- run:
name: Running tests
command: chmod +x ./.circleci/scripts/run_unity_tests.sh && ./.circleci/scripts/run_unity_tests.sh
- store_test_results:
path: test-results

jobs:
test-editmode-2019:
<<: *test-2019
environment:
TEST_PLATFORM: editmode
test-playmode-2019:
<<: *test-2019
environment:
TEST_PLATFORM: playmode

workflows:
version: 2
test:
jobs:
- test-editmode-2019:
context: Unity
- test-playmode-2019:
context: Unity
24 changes: 24 additions & 0 deletions .circleci/scripts/prepare_unity.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

set -e
set -x

mkdir -p /root/.cache/unity3d
mkdir -p /root/.local/share/unity3d/Unity/

set +x

echo "Extracting Unity license file..."
UNITY_LICENSE_CONTENT="${!UNITY_LICENSE_CONTENT_VAR}"
echo "$UNITY_LICENSE_CONTENT" | base64 --decode | tr -d '\r' > /root/.local/share/unity3d/Unity/Unity_lic.ulf

echo "Building Unity project..."
PROJECT_ROOT=$(pwd)
PACKAGE_DEST="$PROJECT_ROOT/Packages/UnityMeshSimplifier"
mkdir -p "$PACKAGE_DEST"
mv Editor "$PACKAGE_DEST/Editor"
mv Runtime "$PACKAGE_DEST/Runtime"

mkdir "$PROJECT_ROOT/Assets"
mkdir "$PROJECT_ROOT/Library"
mkdir "$PROJECT_ROOT/ProjectSettings"
32 changes: 32 additions & 0 deletions .circleci/scripts/run_unity_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash

set -x

echo "Testing for $TEST_PLATFORM"

PROJECT_ROOT="$(pwd)"
TEST_RESULT_DIR="$PROJECT_ROOT/test-results/nunit"
TEST_RESULT_FILE_NAME="$TEST_PLATFORM-results.xml"
TEST_RESULT_FILE_PATH="$TEST_RESULT_DIR/$TEST_RESULT_FILE_NAME"
${UNITY_EXECUTABLE:-xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' /opt/Unity/Editor/Unity} \
-projectPath "$PROJECT_ROOT" \
-runTests \
-testPlatform $TEST_PLATFORM \
-testResults "$TEST_RESULT_FILE_PATH" \
-logFile - \
-batchmode

UNITY_EXIT_CODE=$?

if [ $UNITY_EXIT_CODE -eq 0 ]; then
echo "Run succeeded, no failures occurred";
elif [ $UNITY_EXIT_CODE -eq 2 ]; then
echo "Run succeeded, some tests failed";
elif [ $UNITY_EXIT_CODE -eq 3 ]; then
echo "Run failure (other failure)";
else
echo "Unexpected exit code $UNITY_EXIT_CODE";
fi

cat "$TEST_RESULT_FILE_PATH" | grep test-run | grep Passed
exit $UNITY_TEST_EXIT_CODE
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ insert_final_newline = true
[*.md]
indent_style = space
indent_size = 2

[*.yml]
indent_style = space
indent_size = 2
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ If applicable, add screenshots to help explain your problem.

**Environment (please complete the following information):**
- OS: [e.g. Mac OS]
- Unity Version [e.g. 2019.3.4f1]
- Unity Version: [e.g. 2019.3.4f1]

**Additional context**
Add any other context about the problem here.
4 changes: 2 additions & 2 deletions .github/workflows/commit_message_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: 'Commit Message Check'
on:
push:
branches:
- master
- '*'

jobs:
check-commit-message:
Expand All @@ -17,5 +17,5 @@ jobs:
- name: Check Line Length
uses: gsactions/commit-message-checker@v1
with:
pattern: '^.{1,72}(?:\n.{0,72})*$'
pattern: '^.{1,72}(?:\n.{0,100})*$'
error: 'The maximum line length of 100 characters is exceeded.'
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Every commit must specify at least a **type** and a **subject**. While **scope**
<footer>
```

Any line of the commit message cannot be longer than 72 characters, in order for them to be easy to read in varios git tools.
Any line of the commit message cannot be longer than 100 characters (with the header being maximum 72 characters), in order for them to be easy to read in varios git tools.

**Examples:**

Expand All @@ -62,7 +62,7 @@ docs(readme): added more detailed examples to the readme

All supported commit types:

* **chore**: Changes made to the CI configuration files and scripts.
* **chore**: Changes that aren't relevant to a release.
* **ci**: Changes made to the CI configuration files and scripts.
* **docs**: Changes to documentation.
* **feat**: A new feature.
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

[![openupm](https://img.shields.io/npm/v/com.whinarn.unitymeshsimplifier?label=openupm&registry_uri=https://package.openupm.com)](https://openupm.com/packages/com.whinarn.unitymeshsimplifier/)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/3c6b55bddfe64912b56e6759c642939d)](https://www.codacy.com/manual/Whinarn/UnityMeshSimplifier?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=Whinarn/UnityMeshSimplifier&amp;utm_campaign=Badge_Grade)
[![Release](https://github.com/Whinarn/UnityMeshSimplifier/workflows/Release/badge.svg)](https://github.com/Whinarn/UnityMeshSimplifier/actions?query=workflow%3ARelease)
[![CircleCI](https://img.shields.io/circleci/build/gh/Whinarn/UnityMeshSimplifier?label=circle-ci)](https://circleci.com/gh/Whinarn/UnityMeshSimplifier/tree/master)
[![GitHub Release Status](https://img.shields.io/github/workflow/status/Whinarn/UnityMeshSimplifier/Release?label=release)](https://github.com/Whinarn/UnityMeshSimplifier/actions?query=workflow%3ARelease)
[![License: MIT](https://img.shields.io/badge/License-MIT-brightgreen.svg)](https://github.com/Whinarn/UnityMeshSimplifier/blob/master/LICENSE.md)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)

Mesh simplification for [Unity](https://unity3d.com/). The project is deeply based on the [Fast Quadric Mesh Simplification](https://github.com/sp4cerat/Fast-Quadric-Mesh-Simplification) algorithm, but rewritten entirely in C# and released under the MIT license.

Expand Down Expand Up @@ -49,8 +51,7 @@ You can use [OpenUPM](https://openupm.com/) to install UnityMeshSimplifier.
"com.whinarn.unitymeshsimplifier": "https://github.com/Whinarn/UnityMeshSimplifier.git",
"com.unity.burst": "1.0.4",
"com.unity.mathematics": "1.0.1",
"com.unity.package-manager-ui": "2.1.2",
...
"com.unity.package-manager-ui": "2.1.2"
}
}
```
Expand Down

0 comments on commit e6f7925

Please sign in to comment.