Skip to content

Commit

Permalink
app-pack-gen and unity-app-gen version control
Browse files Browse the repository at this point in the history
  • Loading branch information
edwinsarkissian committed Aug 6, 2024
1 parent 2aa17d0 commit 4272e01
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 6 deletions.
23 changes: 22 additions & 1 deletion gitlab-ci.yml.one_job
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# This pipeline file requires preprocessing. It has three string
# tokens that must be replaces with correct values. The tokens are
# - UVENUE : Unity venue, 'dev', 'test' or 'prod' lowercase only)
# - APGTAG : git tag for the desired version of app-pack-generator
# - UAGTAG : git tag for the desired version of unity-app-generator
# For example, this file can be preprocessed like
# cat gitlab-ci.yml.one_job | sed s/UVENUE/dev/ | sed s/APGTAG/0.4.0/ | sed s/UAGTAG/0.3.0/ > .gitlab-ci.yml


# This is the default section. The "default" keyword (section) lets
# you set default values for other keywords globally. The default
# values can be overridden at different parts of the pipeline when
Expand All @@ -7,6 +16,7 @@ default:
tags:
- unity
- shell
- UVENUE


# This piepline has four stages
Expand Down Expand Up @@ -53,6 +63,15 @@ build-app-gen:
- echo "CI_PROJECT_DIR is $CI_PROJECT_DIR"
- echo "CI_PROJECT_ID is $CI_PROJECT_ID"
- echo "CI_PROJECT_NAME is $CI_PROJECT_NAME"
- TEMPDIR=`date -u +\%Y\%m\%d\%H\%M\%S`_temp
- mkdir ~/$TEMPDIR
- cd ~/$TEMPDIR
- virtualenv venv
- source venv/bin/activate
- git clone --depth 1 --branch APGTAG https://github.com/unity-sds/app-pack-generator.git
- pip3 install app-pack-generator/
- git clone --depth 1 --branch UAGTAG https://github.com/unity-sds/unity-app-generator.git
- pip3 install unity-app-generator/
- docker login -u $DH_USERNAME -p $DH_PASSWORD $DH_REGISTRY_URL
- python3 -m unity_app_generator init $CI_PROJECT_DIR
- cd $CI_PROJECT_DIR
Expand All @@ -61,7 +80,9 @@ build-app-gen:
- python3 -m unity_app_generator build_cwl
- python3 -m unity_app_generator push_app_registry --api_url $APPGEN_DOCKSTORE_URL --token $APPGEN_DOCKSTORE_TOKEN
- docker rmi -f $(docker images -q)

- cd ~
- deactivate
- rm -rf ~/$TEMPDIR

test-app-gen:
stage: test
Expand Down
25 changes: 23 additions & 2 deletions gitlab-ci.yml.one_job_with_trigger
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# This pipeline file requires preprocessing. It has three string
# tokens that must be replaces with correct values. The tokens are
# - UVENUE : Unity venue, 'dev', 'test' or 'prod' lowercase only)
# - APGTAG : git tag for the desired version of app-pack-generator
# - UAGTAG : git tag for the desired version of unity-app-generator
# For example, this file can be preprocessed like
# cat gitlab-ci.yml.one_job | sed s/UVENUE/dev/ | sed s/APGTAG/0.4.0/ | sed s/UAGTAG/0.3.0/ > .gitlab-ci.yml


# This is the default section. The "default" keyword (section) lets
# you set default values for other keywords globally. The default
# values can be overridden at different parts of the pipeline when
Expand All @@ -7,6 +16,7 @@ default:
tags:
- unity
- shell
- UVENUE


# This piepline has four stages
Expand All @@ -31,7 +41,7 @@ stages:
# Even build_cwl must happen after push_docker because the correct
# Docker image location, which is written into the CWL files by
# build_cwl command, is established after push_docker command.
#
#
# The following are needed group-level gitlab CI/CD variables:
# 1) DH_USERNAME: docker hub username
# 2) DH_PASSWORD: docker hub password
Expand All @@ -55,6 +65,15 @@ build-app-gen:
- echo "CI_PROJECT_DIR is $CI_PROJECT_DIR"
- echo "CI_PROJECT_ID is $CI_PROJECT_ID"
- echo "CI_PROJECT_NAME is $CI_PROJECT_NAME"
- TEMPDIR=`date -u +\%Y\%m\%d\%H\%M\%S`_temp
- mkdir ~/$TEMPDIR
- cd ~/$TEMPDIR
- virtualenv venv
- source venv/bin/activate
- git clone --depth 1 --branch APGTAG https://github.com/unity-sds/app-pack-generator.git
- pip3 install app-pack-generator/
- git clone --depth 1 --branch UAGTAG https://github.com/unity-sds/unity-app-generator.git
- pip3 install unity-app-generator/
- docker login -u $DH_USERNAME -p $DH_PASSWORD $DH_REGISTRY_URL
- python3 -m unity_app_generator init $CI_PROJECT_DIR
- cd $CI_PROJECT_DIR
Expand All @@ -63,7 +82,9 @@ build-app-gen:
- python3 -m unity_app_generator build_cwl
- python3 -m unity_app_generator push_app_registry --api_url $APPGEN_DOCKSTORE_URL --token $APPGEN_DOCKSTORE_TOKEN
- docker rmi -f $(docker images -q)

- cd ~
- deactivate
- rm -rf ~/$TEMPDIR

test-app-gen:
stage: test
Expand Down
39 changes: 36 additions & 3 deletions mcp_git_clone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,36 @@
# named .gitlab-ci.yml. The pipeline file is added to the repo
# on a new branch named "mcp_main" to avoid modifying the
# original contents of the source repository to be cloned.
# The cloning tool (this file) will attempt to make a few changes
# to the input pipeline file before creating the final YML file
# .gitlab-ci.yml. This tool will replace the occurrences of three
# string tokens in the input file with other values. The
# replacements are the following:
# * UVENUE: This string token, if it exists, is replaced with
# the value provided through -v argument.
# * APGTAG: This string token, if it exists, is replaced with
# the value provided through -a argument.
# * UAGTAG: This string token, if it exists, is replaced with
# the value provided through -u argument.
#
# -g SGROUP (subgroup) is optional. This is used to select a pre-
# existing subgroup in the Unity group of the Unity MCP GitLab
# account. If provided, the remote repository will be cloned
# in the specified subgroup. If not provided, the remote repo.
# will be cloned directly inside the Unity group.
#
# -v UVENUE (Unity venue) is optional. The valid values are 'dev',
# 'test' and 'prod' (all lower case), and the default value is
# 'dev'
#
# -a APGTAG is optional, and it is the git tag for the repository
# https://github.com/unity-sds/app-pack-generator for the
# desired revision. The default value is '0.4.0'
#
# -u UAGTAG is optional, and it is the git tag for the repository
# https://github.com/unity-sds/unity-app-generator for the
# desired revision. The default value is '0.3.0'
#
# WARNING:
# - There is no strong error checking implemented yet.
# - There are no prompts to confirm the users actions yet.
Expand All @@ -93,7 +116,7 @@
# Prints usage message
#
usage() {
echo "Usage: $0 [ PATH ] [ -b BRANCH ] [ -m MESSAGE ] [ -t TOKEN_NAME:TOKEN ] [ -p PIPELINE ] [ -g SGROUP ]" 1>&2
echo "Usage: $0 [ PATH ] [ -b BRANCH ] [ -m MESSAGE ] [ -t TOKEN_NAME:TOKEN ] [ -p PIPELINE ] [ -g SGROUP ] [ -v UVENUE ] [ -a APGTAG ] [ -u UAGTAG ]" 1>&2
}

# This function is for error exit.
Expand All @@ -113,12 +136,15 @@ message="initial revision"
tauthentication=""
pipeline=""
sgroup=""
uvenue="dev"
apgtag=""
uagtag=""

ipos=0
while [ $# -gt 0 ]; do
unset OPTIND
unset OPTARG
while getopts hb:m:t:p:g: opt; do
while getopts hb:m:t:p:g:v:a:u: opt; do
if [[ ${OPTARG} =~ ^-.*$ ]]; then
echo "ERROR: Option argument cannot start with '-'"
exit_abnormal
Expand All @@ -130,6 +156,9 @@ while [ $# -gt 0 ]; do
t) tauthentication=${OPTARG};;
p) pipeline=`realpath ${OPTARG}`;;
g) sgroup=${OPTARG};;
v) uvenue=${OPTARG};;
a) apgtag=${OPTARG};;
u) uagtag=${OPTARG};;
*) echo "ERROR: Unknown option."; exit_abnormal;;
esac
done
Expand All @@ -154,6 +183,9 @@ echo "token '$tauthentication'"
echo "pipeline '$pipeline'"
echo "sgroup '$sgroup'"
echo "path '$path'"
echo "uvenue '$uvenue'"
echo "apgtag '$apgtag'"
echo "uagtag '$uagtag'"


#=============== Check if "$path" is a valid URL ===============
Expand Down Expand Up @@ -414,7 +446,8 @@ ymlfn_copy=".gitlab-ci.yml"
ymlfn_original=""
if [ ! -z $pipeline ]; then
if [ -f $pipeline ]; then
cp $pipeline ./$ymlfn_copy
# cp $pipeline ./$ymlfn_copy
cat $pipeline | sed s/UVENUE/$uvenue/ | sed s/APGTAG/$apgtag/ | sed s/UAGTAG/$uagtag/ > ./$ymlfn_copy
ymlfn_original=$(basename $pipeline)
else
echo "ERROR: $pipeline does not exist."
Expand Down

0 comments on commit 4272e01

Please sign in to comment.