Skip to content
This repository has been archived by the owner on Dec 5, 2024. It is now read-only.

Commit

Permalink
makes cleanupDanglingUnityFiles run before every unity task (#82)
Browse files Browse the repository at this point in the history
* adds dangling unity assets cleanup task before every unity run

* iupdate java minimum version to java 11
  • Loading branch information
Joaquimmnetto authored Dec 4, 2024
1 parent d80b34d commit eddba00
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 24 deletions.
35 changes: 14 additions & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,32 +1,25 @@
FROM openjdk:8-jdk
ARG RUST_VERSION=1.50.0

FROM rust:$RUST_VERSION
ARG UVM_VERSION=2.2.0

RUN mkdir -p /home/ci

# Create an app user so our program doesn't run as root.
RUN groupadd -r ci &&\
useradd -r -g ci -d /home/ci -s /sbin/nologin -c "Docker image user" ci

# Set the home directory to our app user's home.
ENV HOME=/home/ci
ENV RUST_BACKTRACE=1
ENV RUST_LOG="warning, uvm_core=trace, uvm_jni=trace"
ENV IN_DOCKER="1"

RUN apt-get update
RUN apt-get install -y build-essential libssl-dev pkg-config openssl p7zip-full cpio -y

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
RUN curl -Lo "unity-version-manager-$UVM_VERSION.tar.gz" "https://github.com/Larusso/unity-version-manager/archive/v$UVM_VERSION.tar.gz"
RUN tar -xzf "unity-version-manager-$UVM_VERSION.tar.gz" && rm "unity-version-manager-$UVM_VERSION.tar.gz"

RUN cd "unity-version-manager-$UVM_VERSION" && PATH="${HOME}/.cargo/bin:$PATH" make install

ENV PATH="${HOME}/.cargo/bin:${PATH}"
FROM openjdk:11-jdk-buster
ARG USER_ID=1001
ARG GROUP_ID=100

WORKDIR /home/ci/
RUN useradd -u ${USER_ID} -g ${GROUP_ID} --create-home jenkins_agent

RUN curl -Lo unity-version-manager-2.2.0.tar.gz https://github.com/Larusso/unity-version-manager/archive/v2.2.0.tar.gz && \
tar -xzf unity-version-manager-2.2.0.tar.gz && \
cd unity-version-manager-2.2.0 && make install && \
uvm install 2019.1.0a7 /home/ci/.local/share/Unity-2019.1.0a7
USER jenkins_agent
COPY --from=0 /usr/local/bin/uvm* ./usr/local/bin/

# Chown all the files to the app user.
RUN chown -R ci:ci $HOME
RUN chmod -R 777 $HOME
RUN uvm install 2019.1.0a7 /home/jenkins_agent/.local/share/Unity-2019.1.0a7
4 changes: 3 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ withCredentials([
string(credentialsId: 'atlas_plugins_sonar_token', variable: 'sonar_token'),
string(credentialsId: 'snyk-wooga-frontend-integration-token', variable: 'SNYK_TOKEN')
]) {
buildGradlePlugin platforms: ['macos', 'windows', 'linux'], sonarToken: sonar_token
buildGradlePlugin platforms: ['macos', 'windows', 'linux'],
sonarToken: sonar_token,
dockerArgs: [ dockerArgs: ['-v', '/home/jenkins_agent/.gradle:/home/jenkins_agent/.gradle'] ]
}
7 changes: 5 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

plugins {
id 'net.wooga.plugins' version '5.0.0-rc.2'
id 'net.wooga.plugins' version '5.0.0'
id 'net.wooga.snyk' version '0.12.0'
id 'net.wooga.snyk-gradle-plugin' version '0.6.0'
id "net.wooga.cve-dependency-resolution" version "0.4.0"
Expand All @@ -25,6 +25,9 @@ plugins {
group 'net.wooga.gradle'
description = 'Plugin for wooga unity package development.'

java.sourceCompatibility = JavaVersion.VERSION_11
java.targetCompatibility = JavaVersion.VERSION_11

pluginBundle {
website = 'https://wooga.github.io/atlas-wdk-unity/'
vcsUrl = 'https://github.com/wooga/atlas-wdk-unity'
Expand Down Expand Up @@ -53,7 +56,7 @@ cveHandler {
dependencies {
implementation 'org.apache.maven:maven-artifact:3.8.5'
implementation "net.wooga.gradle:dotnet-sonarqube:[1,2["
implementation "net.wooga.gradle:unity:[4,5["
implementation "net.wooga.gradle:unity:[5,6["
implementation "commons-io:commons-io:2.11.0"
implementation 'com.wooga.gradle:gradle-commons:[1,2['

Expand Down
5 changes: 5 additions & 0 deletions src/main/groovy/wooga/gradle/wdk/unity/WdkUnityPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@ class WdkUnityPlugin implements Plugin<Project> {
}
}

def cleanupUnityFiles = project.tasks.named(UnityPlugin.Tasks.cleanupDanglingUnityFiles.toString())
project.tasks.withType(UnityTask).configureEach {
it.dependsOn(cleanupUnityFiles)
}

// Make every other Unity task depend on the setup task defined by this plugin
project.tasks.withType(UnityTask).configureEach { task ->
if (task.name != RESOLVE_PACKAGES_TASK_NAME && task.name && !(task.name == UnityPlugin.Tasks.ensureProjectManifest.name())
Expand Down
19 changes: 19 additions & 0 deletions src/test/groovy/wooga/gradle/wdk/unity/WdkUnityPluginSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ package wooga.gradle.wdk.unity

import nebula.test.ProjectSpec
import org.gradle.api.DefaultTask
import org.gradle.api.Task
import spock.lang.Unroll
import wooga.gradle.dotnetsonar.DotNetSonarqubePlugin
import wooga.gradle.dotnetsonar.SonarScannerExtension
import wooga.gradle.dotnetsonar.tasks.BuildSolution
import wooga.gradle.unity.UnityPlugin
import wooga.gradle.unity.UnityPluginExtension
import wooga.gradle.unity.UnityTask
import wooga.gradle.wdk.unity.tasks.ResourceCopyTask

class WdkUnityPluginSpec extends ProjectSpec {
Expand Down Expand Up @@ -68,6 +70,23 @@ class WdkUnityPluginSpec extends ProjectSpec {
WdkUnityPlugin.SONARQUBE_TASK_NAME | DefaultTask
}

def 'any UnityTask depends on #dependencies' () {
given:
assert !project.plugins.hasPlugin(PLUGIN_NAME)

when:
project.plugins.apply(PLUGIN_NAME)
and:
def anyUnityTask = project.tasks.register("anyUnityTask", UnityTask).get()

then:
anyUnityTask.getTaskDependencies().getDependencies(anyUnityTask).any { t ->
dependencies.contains(t.name.replaceFirst(":",""))
}
where:
dependencies = [UnityPlugin.Tasks.cleanupDanglingUnityFiles.toString()]
}

@Unroll
def "creates needed configuration #configurationName"() {
given:
Expand Down

0 comments on commit eddba00

Please sign in to comment.