Commit 34778db9 authored by nanahira's avatar nanahira

test ci

parent a63c28c7
Pipeline #34271 failed
stages:
- prepare
- build_and_test
- pack
- deploy
# If you are looking for a place where to add 'UNITY_LICENSE_FILE' and other secrets, please visit your project's gitlab page:
# settings > CI/CD > Variables instead
variables:
GIT_DEPTH: '1'
BUILD_NAME: MDPro3
UNITY_ACTIVATION_FILE: ./unity3d.alf
UNITY_VERSION: "6000.0.10f1"
IMAGE: unityci/editor # https://hub.docker.com/r/unityci/editor
IMAGE_VERSION: "3.1.0" # https://github.com/game-ci/docker/releases
UNITY_DIR: $CI_PROJECT_DIR # this needs to be an absolute path. Defaults to the root of your tree.
image: $IMAGE:$UNITY_VERSION-base-$IMAGE_VERSION
.unity_before_script:
before_script:
- chmod +x ./ci/before_script.sh && ./ci/before_script.sh
.cache:
cache:
key: "$CI_PROJECT_NAMESPACE-$CI_PROJECT_NAME-$CI_COMMIT_REF_SLUG-$TEST_PLATFORM"
paths:
- $UNITY_DIR/Library/
.license:
rules:
- if: '$UNITY_LICENSE != null'
when: always
.unity_defaults:
extends:
- .unity_before_script
- .cache
- .license
.common_image:
image: git-registry.mycard.moe/mycard/docker-runner-base
tags:
- linux
patch_mono:
stage: prepare
dependencies: []
extends: .common_image
script: |
sed -i '/scriptingBackend:/,/\}/s/Standalone: 1/Standalone: 0/' ProjectSettings/ProjectSettings.asset
artifacts:
paths:
- ProjectSettings/ProjectSettings.asset
ocgcore_windows:
stage: ocgcore
dependencies: []
extends: .common_image
script:
- wget -O './Assets/Plugins/YGO Classes/ocgcore.dll' https://cdn02.moecube.com:444/libocgcore-koishi/x64/ocgcore.dll
- wget -O './Assets/Plugins/YGO Classes/sqlite3.dll' https://cdn02.moecube.com:444/libocgcore-koishi/x64/sqlite3.dll
- wget -O './Assets/Plugins/YGO Classes/ygoserver.dll' https://cdn02.moecube.com:444/koishipro/server/windows/ygoserver.dll
artifacts:
paths:
- 'Assets/Plugins/YGO Classes'
# run this job when you need to request a license
# you may need to follow activation steps from documentation
get-activation-file:
rules:
- if: '$UNITY_LICENSE == null'
when: manual
stage: build_and_test
script:
- chmod +x ./ci/get_activation_file.sh && ./ci/get_activation_file.sh
artifacts:
paths:
- $UNITY_ACTIVATION_FILE
expire_in: 10 min # Expiring this as artifacts may contain sensitive data and should not be kept public
.test:
stage: build_and_test
extends: .unity_defaults
script:
- chmod +x ./ci/test.sh && ./ci/test.sh
artifacts:
when: always
expire_in: 2 weeks
# https://gitlab.com/gableroux/unity3d-gitlab-ci-example/-/issues/83
# you may need to remove or replace these to fit your need if you are using your own runners
tags:
- linux
coverage: /<Linecoverage>(.*?)</Linecoverage>/
#test-playmode:
# extends: .test
# variables:
# TEST_PLATFORM: playmode
#test-editmode:
# extends: .test
# variables:
# TEST_PLATFORM: editmode
# uncomment the following blocks if you'd like to have junit reporting unity test results in gitlab
# We currently have the following issue which prevents it from working right now, but you can give
# a hand if you're interested in this feature:
# https://gitlab.com/gableroux/unity3d-gitlab-ci-example/-/issues/151
# .test-with-junit-reports: &test-with-junit-reports
# stage: build_and_test
# extends: .unity_defaults
# script:
# # This could be made faster by adding these packages to base image or running in a separate job (and step)
# # We could use an image with these two depencencies only and only do the saxonb-xslt command on
# # previous job's artifacts
# - apt-get update && apt-get install -y default-jre libsaxonb-java
# - chmod +x ./ci/test.sh && ./ci/test.sh
# - saxonb-xslt -s $UNITY_DIR/$TEST_PLATFORM-results.xml -xsl $CI_PROJECT_DIR/ci/nunit-transforms/nunit3-junit.xslt >$UNITY_DIR/$TEST_PLATFORM-junit-results.xml
# artifacts:
# when: always
# reports:
# junit:
# - $UNITY_DIR/$TEST_PLATFORM-junit-results.xml
# - $UNITY_DIR/$TEST_PLATFORM-coverage/
# expire_in: 2 weeks
# # https://gitlab.com/gableroux/unity3d-gitlab-ci-example/-/issues/83
# # you may need to remove or replace these to fit your need if you are using your own runners
# tags:
# - linux
# coverage: /<Linecoverage>(.*?)</Linecoverage>/
# test-playmode-with-junit-reports:
# extends: .test-with-junit-reports
# variables:
# TEST_PLATFORM: playmode
# test-editmode-with-junit-reports:
# extends: .test-with-junit-reports
# variables:
# TEST_PLATFORM: editmode
.build:
stage: build_and_test
extends: .unity_defaults
script:
- chmod +x ./ci/build.sh && ./ci/build.sh
artifacts:
paths:
- $UNITY_DIR/Builds/
# https://gitlab.com/gableroux/unity3d-gitlab-ci-example/-/issues/83
# you may need to remove or replace these to fit your need if you are using your own runners
tags:
- linux
#build-StandaloneLinux64:
# extends: .build
# dependencies:
# - ocgcore_linux
# variables:
# BUILD_TARGET: StandaloneLinux64
#build-StandaloneLinux64-il2cpp:
# extends: .build
# image: $IMAGE:$UNITY_VERSION-linux-il2cpp-$IMAGE_VERSION
# variables:
# BUILD_TARGET: StandaloneLinux64
# SCRIPTING_BACKEND: IL2CPP
#build-StandaloneOSX:
# extends: .build
# dependencies:
# - ocgcore_macos
# image: $IMAGE:$UNITY_VERSION-mac-mono-$IMAGE_VERSION
# variables:
# BUILD_TARGET: StandaloneOSX
#Note: build target names changed in recent versions, use this for versions < 2017.2:
# build-StandaloneOSXUniversal:
# extends: .build
# variables:
# BUILD_TARGET: StandaloneOSXUniversal
build-StandaloneWindows64:
extends: .build
dependencies:
- patch_mono
- ocgcore_windows
image: $IMAGE:$UNITY_VERSION-windows-mono-$IMAGE_VERSION
variables:
BUILD_TARGET: StandaloneWindows64
......@@ -28,7 +28,7 @@ namespace MDPro3.Servant
Program.instance.currentServant = this;
Program.instance.depth = 0;
StartCoroutine(CheckUpdateAsync());
// StartCoroutine(CheckUpdateAsync());
LoadUI();
}
......
#!/bin/bash
set -x
set -o errexit
apt update && apt -y install wget git libarchive-tools
mkdir -p cdb expansions icon picture/card replay
# ygopro-database
git clone --depth=1 https://code.mycard.moe/mycard/ygopro-database
mv ./ygopro-database/locales/$TARGET_LOCALE/cards.cdb cdb/
cp -rf ./ygopro-database/locales/$TARGET_LOCALE/strings.conf config/
# lflist and translation
wget -O config/lflist.conf 'https://code.mycard.moe/mycard/ygopro/-/raw/master/lflist.conf?inline=false'
cp -rf locales/$TARGET_LOCALE/config/translation.conf ./config/
# script
git clone --depth=1 https://github.com/Fluorohydride/ygopro-scripts script
# ygopro-images
wget -O - https://cdn02.moecube.com:444/images/ygopro-images-${TARGET_LOCALE}.zip | bsdtar -C picture/card -xf -
mv picture/card/field picture/
# closeup
git clone --depth=1 https://code.mycard.moe/mycard/ygopro2-closeup
mv ygopro2-closeup/closeup picture/
# starter pack
git clone --depth=1 https://code.mycard.moe/mycard/ygopro-starter-pack
mv ygopro-starter-pack/deck ./deck
mv ygopro-starter-pack/single ./puzzle
mkdir pack
wget -O pack/pack.db https://cdn02.moecube.com:444/ygopro-card-list/pack.db
#!/usr/bin/env bash
set -e
set -x
mkdir -p /root/.cache/unity3d
mkdir -p /root/.local/share/unity3d/Unity/
set +x
UPPERCASE_BUILD_TARGET=${BUILD_TARGET^^};
if [ $UPPERCASE_BUILD_TARGET = "ANDROID" ]
then
if [ -n $ANDROID_KEYSTORE_BASE64 ]
then
echo '$ANDROID_KEYSTORE_BASE64 found, decoding content into keystore.keystore'
echo $ANDROID_KEYSTORE_BASE64 | base64 --decode > keystore.keystore
else
echo '$ANDROID_KEYSTORE_BASE64'" env var not found, building with Unity's default debug keystore"
fi
fi
LICENSE="UNITY_LICENSE_"$UPPERCASE_BUILD_TARGET
if [ -z "${!LICENSE}" ]
then
echo "$LICENSE env var not found, using default UNITY_LICENSE env var"
LICENSE=UNITY_LICENSE
else
echo "Using $LICENSE env var"
fi
echo "Writing $LICENSE to license file /root/.local/share/unity3d/Unity/Unity_lic.ulf"
echo "${!LICENSE}" | tr -d '\r' > /root/.local/share/unity3d/Unity/Unity_lic.ulf
set -x
#!/usr/bin/env bash
set -e
set -x
if [ -n "$REQUIRED_RESOURCE_DIR" ]; then
if [ ! -d "$REQUIRED_RESOURCE_DIR" ]; then
wget -O - https://cdn02.moecube.com:444/mdpro3-prebuild-resources/$REQUIRED_RESOURCE_DIR.tar.xz | tar -Jxf -
fi
fi
echo "Building for $BUILD_TARGET"
export BUILD_PATH=$UNITY_DIR/Builds/$BUILD_TARGET/
mkdir -p $BUILD_PATH
${UNITY_EXECUTABLE:-xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' unity-editor} \
-projectPath $UNITY_DIR \
-quit \
-batchmode \
-nographics \
-buildTarget $BUILD_TARGET \
-customBuildTarget $BUILD_TARGET \
-customBuildName $BUILD_NAME \
-customBuildPath $BUILD_PATH \
-executeMethod BuildCommand.PerformBuild \
-logFile /dev/stdout
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
ls -la $BUILD_PATH
[ -n "$(ls -A $BUILD_PATH)" ] # fail job if build folder is empty
#!/usr/bin/env bash
set -e
docker run \
-e BUILD_NAME \
-e UNITY_LICENSE \
-e BUILD_TARGET \
-e UNITY_USERNAME \
-e UNITY_PASSWORD \
-w /project/ \
-v $UNITY_DIR:/project/ \
$IMAGE_NAME \
/bin/bash -c "/project/ci/before_script.sh && /project/ci/build.sh"
#!/usr/bin/env bash
set -e
docker run \
-e UNITY_LICENSE \
-e TEST_PLATFORM \
-e UNITY_USERNAME \
-e UNITY_PASSWORD \
-w /project/ \
-v $UNITY_DIR:/project/ \
$IMAGE_NAME \
/bin/bash -c "/project/ci/before_script.sh && /project/ci/test.sh"
#!/usr/bin/env bash
activation_file=${UNITY_ACTIVATION_FILE:-./unity3d.alf}
if [[ -z "${UNITY_USERNAME}" ]] || [[ -z "${UNITY_PASSWORD}" ]]; then
echo "UNITY_USERNAME or UNITY_PASSWORD environment variables are not set, please refer to instructions in the readme and add these to your secret environment variables."
exit 1
fi
xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
unity-editor \
-logFile /dev/stdout \
-batchmode \
-nographics \
-username "$UNITY_USERNAME" -password "$UNITY_PASSWORD" |
tee ./unity-output.log
cat ./unity-output.log |
grep 'LICENSE SYSTEM .* Posting *' |
sed 's/.*Posting *//' > "${activation_file}"
# Fail job if unity.alf is empty
ls "${UNITY_ACTIVATION_FILE:-./unity3d.alf}"
exit_code=$?
if [[ ${exit_code} -eq 0 ]]; then
echo ""
echo ""
echo "### Congratulations! ###"
echo "${activation_file} was generated successfully!"
echo ""
echo "### Next steps ###"
echo ""
echo "Complete the activation process manually"
echo ""
echo " 1. Download the artifact which should contain ${activation_file}"
echo " 2. Visit https://license.unity3d.com/manual"
echo " 3. Upload ${activation_file} in the form"
echo " 4. Answer questions (unity pro vs personal edition, both will work, just pick the one you use)"
echo " 5. Download 'Unity_v2019.x.ulf' file (year should match your unity version here, 'Unity_v2018.x.ulf' for 2018, etc.)"
echo " 6. Copy the content of 'Unity_v2019.x.ulf' license file to your CI's environment variable 'UNITY_LICENSE'. (Open your project's parameters > CI/CD > Variables and add 'UNITY_LICENSE' as the key and paste the content of the license file into the value)"
echo ""
echo "Once you're done, hit retry on the pipeline where other jobs failed, or just push another commit. Things should be green"
echo ""
echo "(optional) For more details on why this is not fully automated, visit https://gitlab.com/gableroux/unity3d-gitlab-ci-example/issues/73"
else
echo "License file could not be found at ${UNITY_ACTIVATION_FILE:-./unity3d.alf}"
fi
exit $exit_code
Copyright (c) 2016 Paul Hicks
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/test-run">
<testsuites tests="{@testcasecount}" failures="{@failed}" disabled="{@skipped}" time="{@duration}">
<xsl:apply-templates/>
</testsuites>
</xsl:template>
<xsl:template match="test-suite">
<xsl:if test="test-case">
<testsuite tests="{@testcasecount}" time="{@duration}" errors="{@testcasecount - @passed - @skipped - @failed}" failures="{@failed}" skipped="{@skipped}" timestamp="{@start-time}">
<xsl:attribute name="name">
<xsl:for-each select="ancestor-or-self::test-suite/@name">
<xsl:value-of select="concat(., '.')"/>
</xsl:for-each>
</xsl:attribute>
<xsl:apply-templates select="test-case"/>
</testsuite>
<xsl:apply-templates select="test-suite"/>
</xsl:if>
<xsl:if test="not(test-case)">
<xsl:apply-templates/>
</xsl:if>
</xsl:template>
<xsl:template match="test-case">
<testcase name="{@name}" assertions="{@asserts}" time="{@duration}" status="{@result}" classname="{@classname}">
<xsl:if test="@runstate = 'Skipped' or @runstate = 'Ignored'">
<skipped/>
</xsl:if>
<xsl:apply-templates/>
</testcase>
</xsl:template>
<xsl:template match="command-line"/>
<xsl:template match="settings"/>
<xsl:template match="output">
<system-out>
<xsl:value-of select="."/>
</system-out>
</xsl:template>
<xsl:template match="stack-trace">
</xsl:template>
<xsl:template match="test-case/failure">
<failure message="{./message}">
<xsl:value-of select="./stack-trace"/>
</failure>
</xsl:template>
<xsl:template match="test-suite/failure"/>
<xsl:template match="test-case/reason">
<skipped message="{./message}"/>
</xsl:template>
<xsl:template match="test-case/assertions">
</xsl:template>
<xsl:template match="test-suite/reason"/>
<xsl:template match="properties"/>
</xsl:stylesheet>
#!/bin/bash
set -x
set -o errexit
apt update && apt -y install tar git zstd
mkdir dist replay expansions icon
cp -rf per-platform/$TARGET_PLATFORM/* . || true
ARCHIVE_FILES=(LICENSE cdb config deck expansions icon pack picture puzzle replay sound texture script)
if [[ "$TARGET_PLATFORM" == "darwin" ]]; then
mv Builds/StandaloneOSX/YGOPro2.app .
ARCHIVE_FILES=("${ARCHIVE_FILES[@]}" YGOPro2.app)
fi
if [[ "$TARGET_PLATFORM" == "linux" ]]; then
mv Builds/StandaloneLinux64/* .
ARCHIVE_FILES=("${ARCHIVE_FILES[@]}" UnityPlayer.so YGOPro2 YGOPro2_Data)
fi
if [[ "$TARGET_PLATFORM" == "win32" ]]; then
mv Builds/StandaloneWindows64/* .
ARCHIVE_FILES=("${ARCHIVE_FILES[@]}" MonoBleedingEdge UnityCrashHandler64.exe UnityPlayer.dll YGOPro2_Data YGOPro2.exe)
fi
ARCHIVE_SUFFIX="zst"
tar -acf "dist/ygopro2-$CI_COMMIT_REF_NAME-$TARGET_PLATFORM-$TARGET_LOCALE.tar.$ARCHIVE_SUFFIX" --exclude='.git*' "${ARCHIVE_FILES[@]}"
#!/usr/bin/env bash
set -x
echo "Testing for $TEST_PLATFORM"
CODE_COVERAGE_PACKAGE="com.unity.testtools.codecoverage"
PACKAGE_MANIFEST_PATH="Packages/manifest.json"
${UNITY_EXECUTABLE:-xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' unity-editor} \
-projectPath $UNITY_DIR \
-runTests \
-testPlatform $TEST_PLATFORM \
-testResults $UNITY_DIR/$TEST_PLATFORM-results.xml \
-logFile /dev/stdout \
-batchmode \
-nographics \
-enableCodeCoverage \
-coverageResultsPath $UNITY_DIR/$TEST_PLATFORM-coverage \
-coverageOptions "generateAdditionalMetrics;generateHtmlReport;generateHtmlReportHistory;generateBadgeReport;assemblyFilters:+Assembly-CSharp" \
-debugCodeOptimization
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
if grep $CODE_COVERAGE_PACKAGE $PACKAGE_MANIFEST_PATH; then
cat $UNITY_DIR/$TEST_PLATFORM-coverage/Report/Summary.xml | grep Linecoverage
mv $UNITY_DIR/$TEST_PLATFORM-coverage/$CI_PROJECT_NAME-opencov/*Mode/TestCoverageResults_*.xml $UNITY_DIR/$TEST_PLATFORM-coverage/coverage.xml
rm -r $UNITY_DIR/$TEST_PLATFORM-coverage/$CI_PROJECT_NAME-opencov/
else
{
echo -e "\033[33mCode Coverage package not found in $PACKAGE_MANIFEST_PATH. Please install the package \"Code Coverage\" through Unity's Package Manager to enable coverage reports.\033[0m"
} 2> /dev/null
fi
cat $UNITY_DIR/$TEST_PLATFORM-results.xml | grep test-run | grep Passed
exit $UNITY_EXIT_CODE
#!/bin/bash
set -o errexit
apt update; apt -y install curl jq
apiRoot=https://api.moecube.com
loginInfo=$(curl -sL -X POST $apiRoot/accounts/signin -d account=$MYCARD_USERNAME -d password=$MYCARD_PASSWORD)
token=$(echo $loginInfo | jq '.token' | sed 's/"//g')
header="Authorization: $token"
echo "Login succeeded."
appName="ygopro2"
handleErrorMessage() {
rawJsonInput="$1"
successInfo=$(echo "$rawJsonInput" | jq '.success')
if [[ "$successInfo" != "true" ]]; then
echo "$rawJsonInput"
exit 1
fi
}
runForDepot() {
platform=$1
locale=$2
archivePath="./dist/$appName-$appVersion-$platform-$locale.tar.zst"
suffix="?platform=$platform&locale=$locale&arch=generic"
echo "Uploading $archivePath"
result=$(curl -H "$header" -X POST "$apiRoot/release/api/build/$appName/${appVersion}${suffix}" -F file=@$archivePath)
handleErrorMessage "$result"
echo "$result" | jq .
}
runForDepot win32 zh-CN
runForDepot linux zh-CN
runForDepot darwin zh-CN
runForDepot win32 en-US
runForDepot linux en-US
runForDepot darwin en-US
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment