From d3082b31283bec6eb27165c0c2444faa2c9607f3 Mon Sep 17 00:00:00 2001 From: Ikiru Yoshizaki <3856350+guitarrapc@users.noreply.github.com> Date: Fri, 6 Oct 2023 00:10:39 +0900 Subject: [PATCH 1/7] ci: add working directory test --- .circleci/test-deploy.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index d0bfeae..284287c 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -92,6 +92,12 @@ jobs: git tag --list count=$(git tag --list | wc -l) if [ $count -eq 0 ]; then exit 1; fi + integration-test-checkout_advanced_workingdir: + docker: + - image: cimg/base:stable + working_directory: ~/test-working-directory + steps: + - git-shallow-clone/checkout_advanced integration-test-checkout_alpine: docker: - image: circleci/redis:6.2.1-alpine @@ -181,6 +187,12 @@ jobs: git tag --list count=$(git tag --list | wc -l) if [ $count -eq 0 ]; then exit 1; fi + integration-test-checkout_workingdir: + docker: + - image: cimg/base:stable + working_directory: ~/test-working-directory + steps: + - git-shallow-clone/checkout integration-test-api-dispatch: docker: - image: cimg/base:stable @@ -219,6 +231,8 @@ workflows: filters: *filters - integration-test-checkout_advanced_tags: filters: *filters + - integration-test-checkout_advanced_workingdir: + filters: *filters - integration-test-checkout_alpine: filters: *filters - integration-test-checkout_depth: @@ -239,6 +253,8 @@ workflows: filters: *filters - integration-test-checkout_tags: filters: *filters + - integration-test-checkout_workingdir: + filters: *filters - integration-test-api-dispatch: filters: *filters context: api @@ -256,7 +272,9 @@ workflows: - integration-test-checkout_advanced_fetchoptions #- integration-test-checkout_advanced_macos - integration-test-checkout_advanced_notags + - integration-test-checkout_advanced_sourcecaching - integration-test-checkout_advanced_tags + - integration-test-checkout_advanced_workingdir - integration-test-checkout_alpine - integration-test-checkout_depth - integration-test-checkout_fetchdepth @@ -265,7 +283,10 @@ workflows: #- integration-test-checkout_macos - integration-test-checkout_notags - integration-test-checkout_path + - integration-test-checkout_sourcechching - integration-test-checkout_tags + - integration-test-checkout_workingdir + - integration-test-api-dispatch context: orb-publisher filters: branches: From 019795878588771d4befeeeda34c866383b0233f Mon Sep 17 00:00:00 2001 From: Ikiru Yoshizaki <3856350+guitarrapc@users.noreply.github.com> Date: Fri, 6 Oct 2023 00:19:38 +0900 Subject: [PATCH 2/7] ci: add working_directory checkout result check --- .circleci/test-deploy.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index 284287c..861d42e 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -97,7 +97,10 @@ jobs: - image: cimg/base:stable working_directory: ~/test-working-directory steps: + - run: pwd && ls -la && [ "$(pwd)" == "$HOME/test-working-directory" ] && echo "working directory is correct" || exit 1 - git-shallow-clone/checkout_advanced + # checkout should be clone to `working_directory`. + - run: pwd && ls -la && [ -d "$HOME/test-working-directory/.git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_alpine: docker: - image: circleci/redis:6.2.1-alpine @@ -192,7 +195,10 @@ jobs: - image: cimg/base:stable working_directory: ~/test-working-directory steps: + - run: pwd && ls -la && [ "$(pwd)" == "$HOME/test-working-directory" ] && echo "working directory is correct" || exit 1 - git-shallow-clone/checkout + # checkout should be clone to `working_directory`. + - run: pwd && ls -la && [ -d "$HOME/test-working-directory/.git" ] && echo "git checkout is correct" || exit 1 integration-test-api-dispatch: docker: - image: cimg/base:stable From 7e0912eb4ef90047d20c3e183c4796a5db62284e Mon Sep 17 00:00:00 2001 From: Ikiru Yoshizaki <3856350+guitarrapc@users.noreply.github.com> Date: Fri, 6 Oct 2023 00:45:36 +0900 Subject: [PATCH 3/7] fix: $CIRCLE_WORKING_DIRECTORY is ~ when working_directory not specified --- src/commands/checkout.yml | 11 ++++++----- src/commands/checkout_advanced.yml | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/commands/checkout.yml b/src/commands/checkout.yml index 157e77a..81a5090 100644 --- a/src/commands/checkout.yml +++ b/src/commands/checkout.yml @@ -113,17 +113,18 @@ steps: fetch_tag_args="--no-tags" fi - # Checkout. SourceCaching? or not. - if [ -e "$CIRCLE_WORKING_DIRECTORY/<< parameters.path >>/.git" ]; then + # Checkout. Expand `$CIRCLE_WORKING_DIRECTORY`'s ~ to `$HOME` and SourceCaching? or not. + working_directory=${CIRCLE_WORKING_DIRECTORY/#\~/$HOME} + if [ -e "$working_directory/<< parameters.path >>/.git" ]; then echo 'Fetching into existing repository' existing_repo='true' - cd "$CIRCLE_WORKING_DIRECTORY/<< parameters.path >>" + cd "$working_directory/<< parameters.path >>" git remote set-url origin "$CIRCLE_REPOSITORY_URL" || true else echo 'Cloning git repository' existing_repo='false' - mkdir -p "$CIRCLE_WORKING_DIRECTORY/<< parameters.path >>" - cd "$CIRCLE_WORKING_DIRECTORY/<< parameters.path >>" + mkdir -p "$working_directory/<< parameters.path >>" + cd "$working_directory/<< parameters.path >>" git clone ${clone_tag_args} --depth << parameters.depth >> $CIRCLE_REPOSITORY_URL . fi diff --git a/src/commands/checkout_advanced.yml b/src/commands/checkout_advanced.yml index 5c122e3..ee2f5d2 100644 --- a/src/commands/checkout_advanced.yml +++ b/src/commands/checkout_advanced.yml @@ -99,17 +99,18 @@ steps: git config --global url."ssh://git@github.com".insteadOf "https://github.com" || true git config --global gc.auto 0 || true - # Checkout. SourceCaching? or not. - if [ -e "$CIRCLE_WORKING_DIRECTORY/<< parameters.path >>/.git" ]; then + # Checkout. Expand `$CIRCLE_WORKING_DIRECTORY`'s ~ to `$HOME` and SourceCaching? or not. + working_directory=${CIRCLE_WORKING_DIRECTORY/#\~/$HOME} + if [ -e "$working_directory/<< parameters.path >>/.git" ]; then echo 'Fetching into existing repository' existing_repo='true' - cd "$CIRCLE_WORKING_DIRECTORY/<< parameters.path >>" + cd "$working_directory/<< parameters.path >>" git remote set-url origin "$CIRCLE_REPOSITORY_URL" || true else echo 'Cloning git repository' existing_repo='false' - mkdir -p "$CIRCLE_WORKING_DIRECTORY/<< parameters.path >>" - cd "$CIRCLE_WORKING_DIRECTORY/<< parameters.path >>" + mkdir -p "$working_directory/<< parameters.path >>" + cd "$working_directory/<< parameters.path >>" git clone << parameters.clone_options >> $CIRCLE_REPOSITORY_URL . fi From 4ea5903b15f437c53555334c8d393cd64128eae0 Mon Sep 17 00:00:00 2001 From: Ikiru Yoshizaki <3856350+guitarrapc@users.noreply.github.com> Date: Fri, 6 Oct 2023 01:18:05 +0900 Subject: [PATCH 4/7] ci: add checkout test to each test --- .circleci/test-deploy.yml | 40 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index 861d42e..043efa7 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -20,17 +20,23 @@ jobs: - image: cimg/base:stable steps: - git-shallow-clone/checkout + - name: test checkout result + run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_advanced: docker: - image: cimg/base:stable steps: - git-shallow-clone/checkout_advanced + - name: test checkout result + run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_advanced_alpine: docker: - image: circleci/redis:6.2.1-alpine steps: - run: apk update && apk add openssh git # openssh is required - git-shallow-clone/checkout_advanced + - name: test checkout result + run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_advanced_fetchoptions: docker: - image: cimg/base:stable @@ -38,11 +44,15 @@ jobs: - git-shallow-clone/checkout_advanced: clone_options: "--depth 100 --single-branch" fetch_options: "--depth 5" + - name: test checkout result + run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_advanced_macos: macos: xcode: 15.0.0 # see: https://circleci.com/docs/using-macos/ steps: - git-shallow-clone/checkout_advanced + - name: test checkout result + run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_advanced_notags: docker: - image: cimg/base:stable @@ -65,6 +75,8 @@ jobs: exit 1 fi fi + - name: test checkout result + run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_advanced_sourcecaching: docker: - image: cimg/base:stable @@ -79,6 +91,8 @@ jobs: key: *source-cache paths: - ".git" + - name: test checkout result + run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_advanced_tags: docker: - image: cimg/base:stable @@ -92,6 +106,8 @@ jobs: git tag --list count=$(git tag --list | wc -l) if [ $count -eq 0 ]; then exit 1; fi + - name: test checkout result + run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_advanced_workingdir: docker: - image: cimg/base:stable @@ -100,13 +116,16 @@ jobs: - run: pwd && ls -la && [ "$(pwd)" == "$HOME/test-working-directory" ] && echo "working directory is correct" || exit 1 - git-shallow-clone/checkout_advanced # checkout should be clone to `working_directory`. - - run: pwd && ls -la && [ -d "$HOME/test-working-directory/.git" ] && echo "git checkout is correct" || exit 1 + - name: test checkout result + run: pwd && ls -la && [ -d "$HOME/test-working-directory/.git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_alpine: docker: - image: circleci/redis:6.2.1-alpine steps: - run: apk update && apk add openssh git # openssh is required - git-shallow-clone/checkout + - name: test checkout result + run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_depth: docker: - image: cimg/base:stable @@ -114,29 +133,39 @@ jobs: - git-shallow-clone/checkout: depth: 5 fetch_depth: 10 + - name: test checkout result + run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_fetchdepth: docker: - image: cimg/base:stable steps: - git-shallow-clone/checkout: fetch_depth: 1 + - name: test checkout result + run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_keyscan_bitbucket: docker: - image: cimg/base:stable steps: - git-shallow-clone/checkout: keyscan_bitbucket: true + - name: test checkout result + run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_keyscan_github: docker: - image: cimg/base:stable steps: - git-shallow-clone/checkout: keyscan_github: true + - name: test checkout result + run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_macos: macos: xcode: 15.0.0 # see: https://circleci.com/docs/using-macos/ steps: - git-shallow-clone/checkout + - name: test checkout result + run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_notags: docker: - image: cimg/base:stable @@ -158,6 +187,8 @@ jobs: exit 1 fi fi + - name: test checkout result + run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_path: docker: - image: cimg/base:stable @@ -178,6 +209,8 @@ jobs: key: *source-cache paths: - ".git" + - name: test checkout result + run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_tags: docker: - image: cimg/base:stable @@ -190,6 +223,8 @@ jobs: git tag --list count=$(git tag --list | wc -l) if [ $count -eq 0 ]; then exit 1; fi + - name: test checkout result + run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_workingdir: docker: - image: cimg/base:stable @@ -198,7 +233,8 @@ jobs: - run: pwd && ls -la && [ "$(pwd)" == "$HOME/test-working-directory" ] && echo "working directory is correct" || exit 1 - git-shallow-clone/checkout # checkout should be clone to `working_directory`. - - run: pwd && ls -la && [ -d "$HOME/test-working-directory/.git" ] && echo "git checkout is correct" || exit 1 + - name: test checkout result + run: pwd && ls -la && [ -d "$HOME/test-working-directory/.git" ] && echo "git checkout is correct" || exit 1 integration-test-api-dispatch: docker: - image: cimg/base:stable From 7a96148e5e17be8c07d49512a0526ac799ad2502 Mon Sep 17 00:00:00 2001 From: Ikiru Yoshizaki <3856350+guitarrapc@users.noreply.github.com> Date: Fri, 6 Oct 2023 01:28:55 +0900 Subject: [PATCH 5/7] ci: circleci config validation --- .circleci/test-deploy.yml | 127 +++++++++++++++++++++++++------------- 1 file changed, 84 insertions(+), 43 deletions(-) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index 043efa7..d4f0274 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -14,29 +14,31 @@ jobs: steps: - checkout - run: git tag --list + # test checkout result + - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 # Define one or more jobs which will utilize your orb's commands and parameters to validate your changes. integration-test-checkout: docker: - image: cimg/base:stable steps: - git-shallow-clone/checkout - - name: test checkout result - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 + # test checkout result + - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_advanced: docker: - image: cimg/base:stable steps: - git-shallow-clone/checkout_advanced - - name: test checkout result - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 + # test checkout result + - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_advanced_alpine: docker: - image: circleci/redis:6.2.1-alpine steps: - run: apk update && apk add openssh git # openssh is required - git-shallow-clone/checkout_advanced - - name: test checkout result - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 + # test checkout result + - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_advanced_fetchoptions: docker: - image: cimg/base:stable @@ -44,15 +46,31 @@ jobs: - git-shallow-clone/checkout_advanced: clone_options: "--depth 100 --single-branch" fetch_options: "--depth 5" - - name: test checkout result - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 + # test checkout result + - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 + integration-test-checkout_advanced_keyscan_bitbucket: + docker: + - image: cimg/base:stable + steps: + - git-shallow-clone/checkout_advanced: + keyscan_bitbucket: true + # test checkout result + - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 + integration-test-checkout_advanced_keyscan_github: + docker: + - image: cimg/base:stable + steps: + - git-shallow-clone/checkout_advanced: + keyscan_github: true + # test checkout result + - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_advanced_macos: macos: xcode: 15.0.0 # see: https://circleci.com/docs/using-macos/ steps: - git-shallow-clone/checkout_advanced - - name: test checkout result - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 + # test checkout result + - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_advanced_notags: docker: - image: cimg/base:stable @@ -75,8 +93,16 @@ jobs: exit 1 fi fi - - name: test checkout result - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 + # test checkout result + - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 + integration-test-checkout_advanced_path: + docker: + - image: cimg/base:stable + steps: + - git-shallow-clone/checkout_advanced: + path: src + # test checkout result + - run: pwd && ls -la && [ -d "$HOME/src/.git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_advanced_sourcecaching: docker: - image: cimg/base:stable @@ -91,8 +117,8 @@ jobs: key: *source-cache paths: - ".git" - - name: test checkout result - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 + # test checkout result + - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_advanced_tags: docker: - image: cimg/base:stable @@ -106,8 +132,8 @@ jobs: git tag --list count=$(git tag --list | wc -l) if [ $count -eq 0 ]; then exit 1; fi - - name: test checkout result - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 + # test checkout result + - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_advanced_workingdir: docker: - image: cimg/base:stable @@ -115,17 +141,16 @@ jobs: steps: - run: pwd && ls -la && [ "$(pwd)" == "$HOME/test-working-directory" ] && echo "working directory is correct" || exit 1 - git-shallow-clone/checkout_advanced - # checkout should be clone to `working_directory`. - - name: test checkout result - run: pwd && ls -la && [ -d "$HOME/test-working-directory/.git" ] && echo "git checkout is correct" || exit 1 + # test checkout result. checkout should be clone to `working_directory`. + - run: pwd && ls -la && [ -d "$HOME/test-working-directory/.git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_alpine: docker: - image: circleci/redis:6.2.1-alpine steps: - run: apk update && apk add openssh git # openssh is required - git-shallow-clone/checkout - - name: test checkout result - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 + # test checkout result + - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_depth: docker: - image: cimg/base:stable @@ -133,39 +158,39 @@ jobs: - git-shallow-clone/checkout: depth: 5 fetch_depth: 10 - - name: test checkout result - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 + # test checkout result + - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_fetchdepth: docker: - image: cimg/base:stable steps: - git-shallow-clone/checkout: fetch_depth: 1 - - name: test checkout result - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 + # test checkout result + - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_keyscan_bitbucket: docker: - image: cimg/base:stable steps: - git-shallow-clone/checkout: keyscan_bitbucket: true - - name: test checkout result - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 + # test checkout result + - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_keyscan_github: docker: - image: cimg/base:stable steps: - git-shallow-clone/checkout: keyscan_github: true - - name: test checkout result - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 + # test checkout result + - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_macos: macos: xcode: 15.0.0 # see: https://circleci.com/docs/using-macos/ steps: - git-shallow-clone/checkout - - name: test checkout result - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 + # test checkout result + - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_notags: docker: - image: cimg/base:stable @@ -187,14 +212,16 @@ jobs: exit 1 fi fi - - name: test checkout result - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 + # test checkout result + - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_path: docker: - image: cimg/base:stable steps: - git-shallow-clone/checkout: path: src + # test checkout result + - run: pwd && ls -la && [ -d "$HOME/src/.git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_sourcechching: docker: - image: cimg/base:stable @@ -209,8 +236,8 @@ jobs: key: *source-cache paths: - ".git" - - name: test checkout result - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 + # test checkout result + - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_tags: docker: - image: cimg/base:stable @@ -223,8 +250,8 @@ jobs: git tag --list count=$(git tag --list | wc -l) if [ $count -eq 0 ]; then exit 1; fi - - name: test checkout result - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 + # test checkout result + - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_workingdir: docker: - image: cimg/base:stable @@ -232,9 +259,8 @@ jobs: steps: - run: pwd && ls -la && [ "$(pwd)" == "$HOME/test-working-directory" ] && echo "working directory is correct" || exit 1 - git-shallow-clone/checkout - # checkout should be clone to `working_directory`. - - name: test checkout result - run: pwd && ls -la && [ -d "$HOME/test-working-directory/.git" ] && echo "git checkout is correct" || exit 1 + # test checkout result. checkout should be clone to `working_directory`. + - run: pwd && ls -la && [ -d "$HOME/test-working-directory/.git" ] && echo "git checkout is correct" || exit 1 integration-test-api-dispatch: docker: - image: cimg/base:stable @@ -257,24 +283,32 @@ workflows: # Run any integration tests defined within the `jobs` key. - normal-checkout: filters: *filters - - integration-test-checkout: - filters: *filters + # ---- checkout_advanced ---- - integration-test-checkout_advanced: filters: *filters - integration-test-checkout_advanced_alpine: filters: *filters - integration-test-checkout_advanced_fetchoptions: filters: *filters + - integration-test-checkout_advanced_keyscan_bitbucket: + filters: *filters + - integration-test-checkout_advanced_keyscan_github: + filters: *filters # - integration-test-checkout_advanced_macos: # filters: *filters - integration-test-checkout_advanced_notags: filters: *filters + - integration-test-checkout_advanced_path: + filters: *filters - integration-test-checkout_advanced_sourcecaching: filters: *filters - integration-test-checkout_advanced_tags: filters: *filters - integration-test-checkout_advanced_workingdir: filters: *filters + # ---- checkout_advanced ---- + - integration-test-checkout: + filters: *filters - integration-test-checkout_alpine: filters: *filters - integration-test-checkout_depth: @@ -297,6 +331,7 @@ workflows: filters: *filters - integration-test-checkout_workingdir: filters: *filters + # ---- api ---- - integration-test-api-dispatch: filters: *filters context: api @@ -308,15 +343,20 @@ workflows: pub-type: production requires: - orb-tools/pack - - integration-test-checkout + # ---- checkout_advanced ---- - integration-test-checkout_advanced - integration-test-checkout_advanced_alpine - integration-test-checkout_advanced_fetchoptions + - integration-test-checkout_advanced_keyscan_bitbucket + - integration-test-checkout_advanced_keyscan_github #- integration-test-checkout_advanced_macos - integration-test-checkout_advanced_notags + - integration-test-checkout_advanced_path - integration-test-checkout_advanced_sourcecaching - integration-test-checkout_advanced_tags - integration-test-checkout_advanced_workingdir + # ---- checkout ---- + - integration-test-checkout - integration-test-checkout_alpine - integration-test-checkout_depth - integration-test-checkout_fetchdepth @@ -328,6 +368,7 @@ workflows: - integration-test-checkout_sourcechching - integration-test-checkout_tags - integration-test-checkout_workingdir + # ---- api ---- - integration-test-api-dispatch context: orb-publisher filters: From a67d4652463a702934f2f95a4934107a7f2ee3e4 Mon Sep 17 00:00:00 2001 From: Ikiru Yoshizaki <3856350+guitarrapc@users.noreply.github.com> Date: Fri, 6 Oct 2023 01:36:15 +0900 Subject: [PATCH 6/7] ci: show pwd and $HOME, remove $HOME from test path --- .circleci/test-deploy.yml | 52 +++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index d4f0274..fb27dc3 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -15,7 +15,7 @@ jobs: - checkout - run: git tag --list # test checkout result - - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 + - run: echo "pwd=$(pwd)" && echo "HOME=$HOME" && ls -la && [ -d ".git" ] && echo "git checkout is correct" || exit 1 # Define one or more jobs which will utilize your orb's commands and parameters to validate your changes. integration-test-checkout: docker: @@ -23,14 +23,14 @@ jobs: steps: - git-shallow-clone/checkout # test checkout result - - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 + - run: echo "pwd=$(pwd)" && echo "HOME=$HOME" && ls -la && [ -d ".git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_advanced: docker: - image: cimg/base:stable steps: - git-shallow-clone/checkout_advanced # test checkout result - - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 + - run: echo "pwd=$(pwd)" && echo "HOME=$HOME" && ls -la && [ -d ".git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_advanced_alpine: docker: - image: circleci/redis:6.2.1-alpine @@ -38,7 +38,7 @@ jobs: - run: apk update && apk add openssh git # openssh is required - git-shallow-clone/checkout_advanced # test checkout result - - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 + - run: echo "pwd=$(pwd)" && echo "HOME=$HOME" && ls -la && [ -d ".git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_advanced_fetchoptions: docker: - image: cimg/base:stable @@ -47,7 +47,7 @@ jobs: clone_options: "--depth 100 --single-branch" fetch_options: "--depth 5" # test checkout result - - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 + - run: echo "pwd=$(pwd)" && echo "HOME=$HOME" && ls -la && [ -d ".git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_advanced_keyscan_bitbucket: docker: - image: cimg/base:stable @@ -55,7 +55,7 @@ jobs: - git-shallow-clone/checkout_advanced: keyscan_bitbucket: true # test checkout result - - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 + - run: echo "pwd=$(pwd)" && echo "HOME=$HOME" && ls -la && [ -d ".git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_advanced_keyscan_github: docker: - image: cimg/base:stable @@ -63,14 +63,14 @@ jobs: - git-shallow-clone/checkout_advanced: keyscan_github: true # test checkout result - - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 + - run: echo "pwd=$(pwd)" && echo "HOME=$HOME" && ls -la && [ -d ".git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_advanced_macos: macos: xcode: 15.0.0 # see: https://circleci.com/docs/using-macos/ steps: - git-shallow-clone/checkout_advanced # test checkout result - - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 + - run: echo "pwd=$(pwd)" && echo "HOME=$HOME" && ls -la && [ -d ".git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_advanced_notags: docker: - image: cimg/base:stable @@ -94,7 +94,7 @@ jobs: fi fi # test checkout result - - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 + - run: echo "pwd=$(pwd)" && echo "HOME=$HOME" && ls -la && [ -d ".git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_advanced_path: docker: - image: cimg/base:stable @@ -102,7 +102,7 @@ jobs: - git-shallow-clone/checkout_advanced: path: src # test checkout result - - run: pwd && ls -la && [ -d "$HOME/src/.git" ] && echo "git checkout is correct" || exit 1 + - run: echo "pwd=$(pwd)" && echo "HOME=$HOME" && ls -la && [ -d "./src/.git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_advanced_sourcecaching: docker: - image: cimg/base:stable @@ -118,7 +118,7 @@ jobs: paths: - ".git" # test checkout result - - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 + - run: echo "pwd=$(pwd)" && echo "HOME=$HOME" && ls -la && [ -d ".git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_advanced_tags: docker: - image: cimg/base:stable @@ -133,16 +133,16 @@ jobs: count=$(git tag --list | wc -l) if [ $count -eq 0 ]; then exit 1; fi # test checkout result - - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 + - run: echo "pwd=$(pwd)" && echo "HOME=$HOME" && ls -la && [ -d ".git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_advanced_workingdir: docker: - image: cimg/base:stable working_directory: ~/test-working-directory steps: - - run: pwd && ls -la && [ "$(pwd)" == "$HOME/test-working-directory" ] && echo "working directory is correct" || exit 1 + - run: echo "pwd=$(pwd)" && echo "HOME=$HOME" && ls -la && [ "$(pwd)" == "$HOME/test-working-directory" ] && echo "working directory is correct" || exit 1 - git-shallow-clone/checkout_advanced # test checkout result. checkout should be clone to `working_directory`. - - run: pwd && ls -la && [ -d "$HOME/test-working-directory/.git" ] && echo "git checkout is correct" || exit 1 + - run: echo "pwd=$(pwd)" && echo "HOME=$HOME" && ls -la && [ -d "$HOME/test-working-directory/.git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_alpine: docker: - image: circleci/redis:6.2.1-alpine @@ -150,7 +150,7 @@ jobs: - run: apk update && apk add openssh git # openssh is required - git-shallow-clone/checkout # test checkout result - - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 + - run: echo "pwd=$(pwd)" && echo "HOME=$HOME" && ls -la && [ -d ".git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_depth: docker: - image: cimg/base:stable @@ -159,7 +159,7 @@ jobs: depth: 5 fetch_depth: 10 # test checkout result - - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 + - run: echo "pwd=$(pwd)" && echo "HOME=$HOME" && ls -la && [ -d ".git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_fetchdepth: docker: - image: cimg/base:stable @@ -167,7 +167,7 @@ jobs: - git-shallow-clone/checkout: fetch_depth: 1 # test checkout result - - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 + - run: echo "pwd=$(pwd)" && echo "HOME=$HOME" && ls -la && [ -d ".git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_keyscan_bitbucket: docker: - image: cimg/base:stable @@ -175,7 +175,7 @@ jobs: - git-shallow-clone/checkout: keyscan_bitbucket: true # test checkout result - - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 + - run: echo "pwd=$(pwd)" && echo "HOME=$HOME" && ls -la && [ -d ".git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_keyscan_github: docker: - image: cimg/base:stable @@ -183,14 +183,14 @@ jobs: - git-shallow-clone/checkout: keyscan_github: true # test checkout result - - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 + - run: echo "pwd=$(pwd)" && echo "HOME=$HOME" && ls -la && [ -d ".git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_macos: macos: xcode: 15.0.0 # see: https://circleci.com/docs/using-macos/ steps: - git-shallow-clone/checkout # test checkout result - - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 + - run: echo "pwd=$(pwd)" && echo "HOME=$HOME" && ls -la && [ -d ".git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_notags: docker: - image: cimg/base:stable @@ -213,7 +213,7 @@ jobs: fi fi # test checkout result - - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 + - run: echo "pwd=$(pwd)" && echo "HOME=$HOME" && ls -la && [ -d ".git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_path: docker: - image: cimg/base:stable @@ -221,7 +221,7 @@ jobs: - git-shallow-clone/checkout: path: src # test checkout result - - run: pwd && ls -la && [ -d "$HOME/src/.git" ] && echo "git checkout is correct" || exit 1 + - run: echo "pwd=$(pwd)" && echo "HOME=$HOME" && ls -la && [ -d "./src/.git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_sourcechching: docker: - image: cimg/base:stable @@ -237,7 +237,7 @@ jobs: paths: - ".git" # test checkout result - - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 + - run: echo "pwd=$(pwd)" && echo "HOME=$HOME" && ls -la && [ -d ".git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_tags: docker: - image: cimg/base:stable @@ -251,16 +251,16 @@ jobs: count=$(git tag --list | wc -l) if [ $count -eq 0 ]; then exit 1; fi # test checkout result - - run: pwd && ls -la && [ -d "$HOME/.git" ] && echo "git checkout is correct" || exit 1 + - run: echo "pwd=$(pwd)" && echo "HOME=$HOME" && ls -la && [ -d ".git" ] && echo "git checkout is correct" || exit 1 integration-test-checkout_workingdir: docker: - image: cimg/base:stable working_directory: ~/test-working-directory steps: - - run: pwd && ls -la && [ "$(pwd)" == "$HOME/test-working-directory" ] && echo "working directory is correct" || exit 1 + - run: echo "pwd=$(pwd)" && echo "HOME=$HOME" && ls -la && [ "$(pwd)" == "$HOME/test-working-directory" ] && echo "working directory is correct" || exit 1 - git-shallow-clone/checkout # test checkout result. checkout should be clone to `working_directory`. - - run: pwd && ls -la && [ -d "$HOME/test-working-directory/.git" ] && echo "git checkout is correct" || exit 1 + - run: echo "pwd=$(pwd)" && echo "HOME=$HOME" && ls -la && [ -d "$HOME/test-working-directory/.git" ] && echo "git checkout is correct" || exit 1 integration-test-api-dispatch: docker: - image: cimg/base:stable From 4d8635c7cd30e10d82c4cc59a4a8c92f4eca229e Mon Sep 17 00:00:00 2001 From: Ikiru Yoshizaki <3856350+guitarrapc@users.noreply.github.com> Date: Fri, 6 Oct 2023 02:08:21 +0900 Subject: [PATCH 7/7] feat: support /bin/sh for $CIRCLE_WORKING_DIRECTORY --- src/commands/checkout.yml | 10 ++++++++-- src/commands/checkout_advanced.yml | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/commands/checkout.yml b/src/commands/checkout.yml index 81a5090..8fca1a3 100644 --- a/src/commands/checkout.yml +++ b/src/commands/checkout.yml @@ -113,8 +113,14 @@ steps: fetch_tag_args="--no-tags" fi - # Checkout. Expand `$CIRCLE_WORKING_DIRECTORY`'s ~ to `$HOME` and SourceCaching? or not. - working_directory=${CIRCLE_WORKING_DIRECTORY/#\~/$HOME} + # Replace "~" in `$CIRCLE_WORKING_DIRECTORY` to `$HOME` + if [ "$0" == "/bin/bash" ]; then + working_directory=${CIRCLE_WORKING_DIRECTORY/#\~/$HOME} + else + working_directory=$(echo "$CIRCLE_WORKING_DIRECTORY" | sed -e "s|^~|$HOME|g") + fi + + # Checkout. SourceCaching? or not. if [ -e "$working_directory/<< parameters.path >>/.git" ]; then echo 'Fetching into existing repository' existing_repo='true' diff --git a/src/commands/checkout_advanced.yml b/src/commands/checkout_advanced.yml index ee2f5d2..7f1cf6e 100644 --- a/src/commands/checkout_advanced.yml +++ b/src/commands/checkout_advanced.yml @@ -99,8 +99,14 @@ steps: git config --global url."ssh://git@github.com".insteadOf "https://github.com" || true git config --global gc.auto 0 || true - # Checkout. Expand `$CIRCLE_WORKING_DIRECTORY`'s ~ to `$HOME` and SourceCaching? or not. - working_directory=${CIRCLE_WORKING_DIRECTORY/#\~/$HOME} + # Expand `$CIRCLE_WORKING_DIRECTORY`'s ~ to `$HOME` + if [ "$0" == "/bin/sh" ]; then + working_directory=$(echo "$CIRCLE_WORKING_DIRECTORY" | sed -e "s|^~|$HOME|g") + else + working_directory=${CIRCLE_WORKING_DIRECTORY/#\~/$HOME} + fi + + # Checkout. SourceCaching? or not. if [ -e "$working_directory/<< parameters.path >>/.git" ]; then echo 'Fetching into existing repository' existing_repo='true'