From 6a37c9c90bf6a6103d0375b7dc8696af147f762f Mon Sep 17 00:00:00 2001 From: Harrison Deng Date: Mon, 22 Jul 2024 04:54:33 +0000 Subject: [PATCH] Added devcontainer and updated pipeline. --- .devcontainer/Dockerfile | 11 ------- .devcontainer/devcontainer.json | 33 ++++++++----------- .devcontainer/noop.txt | 3 -- .vscode/launch.json | 8 +++-- Jenkinsfile | 21 +++++++----- environment.yml | 4 +-- islandsurvivalcraft.code-workspace | 21 ------------ .../IslandSurvivalCraftPlugin.java | 21 ------------ test-server/start_normal.ps1 | 2 +- 9 files changed, 35 insertions(+), 89 deletions(-) delete mode 100644 .devcontainer/Dockerfile delete mode 100644 .devcontainer/noop.txt delete mode 100644 islandsurvivalcraft.code-workspace delete mode 100644 src/main/java/ca/recrown/islandsurvivalcraft/IslandSurvivalCraftPlugin.java diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile deleted file mode 100644 index 2738918..0000000 --- a/.devcontainer/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -FROM mcr.microsoft.com/devcontainers/anaconda:1-3 - -# Copy environment.yml (if found) to a temp location so we update the environment. Also -# copy "noop.txt" so the COPY instruction does not fail if no environment.yml exists. -COPY environment.yml* .devcontainer/noop.txt /tmp/conda-tmp/ -RUN if [ -f "/tmp/conda-tmp/environment.yml" ]; then umask 0002 && /opt/conda/bin/conda env update -n base -f /tmp/conda-tmp/environment.yml; fi \ - && rm -rf /tmp/conda-tmp - -# [Optional] Uncomment this section to install additional OS packages. -# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ -# && apt-get -y install --no-install-recommends diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index f7db739..3b6ac19 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,31 +1,24 @@ // For format details, see https://aka.ms/devcontainer.json. For config options, see the -// README at: https://github.com/devcontainers/templates/tree/main/src/anaconda +// README at: https://github.com/devcontainers/templates/tree/main/src/java { - "name": "Anaconda (Python 3)", - "build": { - "context": "..", - "dockerfile": "Dockerfile" - }, - "customizations": { - "vscode": { - "extensions": [ - "vscjava.vscode-java-test", - "vscjava.vscode-java-dependency", - "vscjava.vscode-maven", - "redhat.java", - "vscjava.vscode-java-debug" - ] - } - } + "name": "Java", + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "image": "mcr.microsoft.com/devcontainers/java:1-11-bullseye", - // Features to add to the dev container. More info: https://containers.dev/features. - // "features": {}, + "features": { + "ghcr.io/devcontainers/features/java:1": { + "version": "none", + "installMaven": "true", + "installGradle": "true" + }, + "ghcr.io/devcontainers/features/powershell:1": {} + } // Use 'forwardPorts' to make a list of ports inside the container available locally. // "forwardPorts": [], // Use 'postCreateCommand' to run commands after the container is created. - // "postCreateCommand": "python --version", + // "postCreateCommand": "java -version", // Configure tool-specific properties. // "customizations": {}, diff --git a/.devcontainer/noop.txt b/.devcontainer/noop.txt deleted file mode 100644 index dde8dc3..0000000 --- a/.devcontainer/noop.txt +++ /dev/null @@ -1,3 +0,0 @@ -This file copied into the container along with environment.yml* from the parent -folder. This file is included to prevents the Dockerfile COPY instruction from -failing if no environment.yml is found. \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index 3c72040..b741431 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -4,6 +4,12 @@ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ + { + "type": "java", + "request": "attach", + "name": "Attach by Process ID", + "processId": "${command:PickJavaProcess}" + }, { "type": "java", "name": "Debug (Launch) - Current File", @@ -19,8 +25,6 @@ "sourcePaths": [ "src/main/java" ], - "preLaunchTask": "start test server", - "postDebugTask": "stop test server" } ] } \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile index f1012fe..b40b6b8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,27 +1,32 @@ pipeline { - agent any + agent { + kubernetes { + cloud 'Reslate Systems' + defaultContainer 'conda' + } + } stages { stage ("Install") { steps { - sh 'mamba env update --file environment.yml' - sh 'echo "mamba activate islandsurvivalcraft" >> ~/.bashrc' - sh "mvn validate" + sh 'conda update conda -y -q' + sh 'conda env update -n base --file environment.yml -q' + sh "conda run -n base mvn validate" } } stage ("Build") { steps { - sh "mvn compile" + sh "conda run -n base mvn compile" } } stage ("Test") { steps { - sh "mvn -Dmaven.test.skip=false test" - junit 'target/surefire-reports/TEST-*.xml' + sh "conda run -n base mvn -Dmaven.test.skip=false test" + recordCoverage(tools: [[parser: 'JUNIT', pattern: 'target/surefire-reports/TEST-*.xml']]) } } stage ("Package") { steps { - sh "mvn package" + sh "conda run -n base mvn package" archiveArtifacts artifacts: 'target/*.jar', fingerprint: true, followSymlinks: false } } diff --git a/environment.yml b/environment.yml index a7c8b01..0314f2f 100644 --- a/environment.yml +++ b/environment.yml @@ -2,5 +2,5 @@ name: islandsurvivalcraft channels: - conda-forge dependencies: - - openjdk=11.0.* - - maven=3.8.* \ No newline at end of file + - openjdk=21 + - maven \ No newline at end of file diff --git a/islandsurvivalcraft.code-workspace b/islandsurvivalcraft.code-workspace deleted file mode 100644 index 604dffa..0000000 --- a/islandsurvivalcraft.code-workspace +++ /dev/null @@ -1,21 +0,0 @@ -{ - "folders": [ - { - "path": "." - } - ], - "settings": { - "java.configuration.updateBuildConfiguration": "automatic", - "files.exclude": { - "**/.classpath": true, - "**/.project": true, - "**/.settings": true, - "**/.factorypath": true - }, - "cSpell.words": [ - "Bukkit", - "crafter", - "itemstack" - ] - } -} \ No newline at end of file diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/IslandSurvivalCraftPlugin.java b/src/main/java/ca/recrown/islandsurvivalcraft/IslandSurvivalCraftPlugin.java deleted file mode 100644 index 4a3fe77..0000000 --- a/src/main/java/ca/recrown/islandsurvivalcraft/IslandSurvivalCraftPlugin.java +++ /dev/null @@ -1,21 +0,0 @@ -package ca.recrown.islandsurvivalcraft; - -import org.bukkit.plugin.java.JavaPlugin; - -/** - * Hello world! - * - */ -public class IslandSurvivalCraftPlugin extends JavaPlugin { - @Override - public void onEnable() { - // TODO Auto-generated method stub - super.onEnable(); - } - - @Override - public void onDisable() { - // TODO Auto-generated method stub - super.onDisable(); - } -} diff --git a/test-server/start_normal.ps1 b/test-server/start_normal.ps1 index 3974069..8cbf7e6 100644 --- a/test-server/start_normal.ps1 +++ b/test-server/start_normal.ps1 @@ -1 +1 @@ -Start-Process java -ArgumentList "-Xms512M", "-Xmx1G", "-jar", "craftbukkit.jar", "nogui" \ No newline at end of file +Start-Process java -ArgumentList "-Xms512M", "-Xmx1G", "-jar", "paper.jar", "nogui" \ No newline at end of file