From 754c3e038751cedf798b6e28dd3384e6c6a98a3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Serdar=20=C3=96zer?= Date: Tue, 18 Nov 2025 12:08:34 +0100 Subject: [PATCH 01/14] feat: alioss github workflow is added - scripts to run, teardown and setup are added. --- .github/scripts/alioss/run-int.sh | 28 ++++++++++ .github/scripts/alioss/setup.sh | 28 ++++++++++ .github/scripts/alioss/teardown.sh | 26 ++++++++++ .github/scripts/alioss/utils.sh | 51 +++++++++++++++++++ .github/workflows/alioss-integration copy.yml | 36 +++++++++++++ 5 files changed, 169 insertions(+) create mode 100755 .github/scripts/alioss/run-int.sh create mode 100755 .github/scripts/alioss/setup.sh create mode 100755 .github/scripts/alioss/teardown.sh create mode 100755 .github/scripts/alioss/utils.sh create mode 100644 .github/workflows/alioss-integration copy.yml diff --git a/.github/scripts/alioss/run-int.sh b/.github/scripts/alioss/run-int.sh new file mode 100755 index 0000000..ca78057 --- /dev/null +++ b/.github/scripts/alioss/run-int.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +set -euo pipefail + +script_dir="$( cd "$(dirname "${0}")" && pwd )" +repo_root="$(cd "${script_dir}/../../.." && pwd)" + +: "${access_key_id:?}" +: "${access_key_secret:?}" +: "${test_name:=general}" +: "${region:=cn-hangzhou}" + +export ACCESS_KEY_ID="${access_key_id}" +export ACCESS_KEY_SECRET="${secret_access_key}" + +pushd "${script_dir}" > /dev/null + source utils.sh + bucket_name="$(read_bucket_name_from_file "${test_name}")" + : "${bucket_name:?}" + export BUCKET_NAME="${bucket_name}" +popd > /dev/null + +export ENDPOINT="https://${BUCKET_NAME}.${region}.aliyuncs.com" + +pushd "${repo_root}" > /dev/null + echo -e "\n running tests with $(go version)..." + ginkgo -r alioss/integration/ +popd > /dev/null + diff --git a/.github/scripts/alioss/setup.sh b/.github/scripts/alioss/setup.sh new file mode 100755 index 0000000..4d29a9a --- /dev/null +++ b/.github/scripts/alioss/setup.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +set -euo pipefail + +script_dir="$( cd "$(dirname "${0}")" && pwd )" +repo_root="$(cd "${script_dir}/../../.." && pwd)" + + + +: "${access_key_id:?}" +: "${access_key_secret:?}" +: "${profile:=integration-tests}" +: "${test_name:=general}" +: "${region:=cn-hangzhou}" + + +export ALI_ACCESS_KEY_ID="${access_key_id}" +export ALI_ACCESS_KEY_SECRET="${secret_access_key}" +export ALI_REGION="${region}" +export ALI_PROFILE="${profile}" + + + +pushd "${script_dir}" + source utils.sh + generate_bucket_name "${test_name}" + aliyun_configure + create_bucket "${test_name}" +popd diff --git a/.github/scripts/alioss/teardown.sh b/.github/scripts/alioss/teardown.sh new file mode 100755 index 0000000..e9c0907 --- /dev/null +++ b/.github/scripts/alioss/teardown.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +set -euo pipefail + +script_dir="$( cd "$(dirname "${0}")" && pwd )" +repo_root="$(cd "${script_dir}/../../.." && pwd)" + + +: "${access_key_id:?}" +: "${access_key_secret:?}" +: "${profile:=integration-tests}" +: "${test_name:=general}" +: "${region:=cn-hangzhou}" + +export ALI_ACCESS_KEY_ID="${access_key_id}" +export ALI_ACCESS_KEY_SECRET="${secret_access_key}" +export ALI_REGION="${region}" +export ALI_PROFILE="${profile}" + + + +pushd "${script_dir}" + source utils.sh + aliyun_configure + delete_bucket "${test_name}" + delete_bucket_name_file "${test_name}" +popd diff --git a/.github/scripts/alioss/utils.sh b/.github/scripts/alioss/utils.sh new file mode 100755 index 0000000..6149284 --- /dev/null +++ b/.github/scripts/alioss/utils.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash + +TMP_DIR="/tmp/storage-cli-alioss-${GITHUB_RUN_ID:-${USER}}" + +# generate a random bucket name with "alioss-" prefix +function random_name { + echo "alioss-$(openssl rand -hex 20)" +} + + +# create a file with .lock suffix and store the bucket name inside it +function generate_bucket_name { + local file_name="${1}.lock" + local bucket_name="$(random_name)" + mkdir -p "${TMP_DIR}" + echo "${bucket_name}" > "${TMP_DIR}/${file_name}" +} + + +# retrieve the bucket name from the .lock file +function read_bucket_name_from_file { + local file_name="$1" + cat "${TMP_DIR}/${file_name}.lock" +} + +# delete the .lock file +function delete_bucket_name_file { + local file_name="$1" + rm -f "${TMP_DIR}/${file_name}.lock" +} + + +function aliyun_configure { + aliyun configure set --profile "$ALI_PROFILE" \ + --access-key-id "$ALI_ACCESS_KEY_ID" \ + --access-key-secret "$ALI_ACCESS_KEY_SECRET" \ + --region "$ALI_REGION" +} + + + +function create_bucket { + local bucket_name="$(read_bucket_name_from_file "$1")" + aliyun --profile "$ALI_PROFILE" oss mb "oss://$bucket_name" +} + + +function delete_bucket { + local bucket_name="$(read_bucket_name_from_file "$1")" + aliyun --profile "$ALI_PROFILE" oss rb "oss://$bucket_name" --force +} \ No newline at end of file diff --git a/.github/workflows/alioss-integration copy.yml b/.github/workflows/alioss-integration copy.yml new file mode 100644 index 0000000..0759e47 --- /dev/null +++ b/.github/workflows/alioss-integration copy.yml @@ -0,0 +1,36 @@ +on: + push: + pull_request: + +jobs: + alioss-general-integration-tests: + name: Alioss Environment Integration Tests + runs-on: ubuntu-latest + environment: alioss-integration + steps: + - name: Checkout code + uses: actions/checkout@v5 + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version-file: go.mod + - name: Install Ginkgo + run: go install github.com/onsi/ginkgo/v2/ginkgo@latest + - name: Setup Alioss Test Environment + run: | + export access_key_id="${{ secrets.ALI_ACCESS_KEY_ID }}" + export access_key_secret="${{ secrets.ALI_ACCESS_KEY_SECRET }}" + export profile="${{ secrets.ALI_PROFILE_NAME }}" + ./.github/scripts/alioss/setup.sh + - name: Run Tests + run: | + export access_key_id="${{ secrets.ALI_ACCESS_KEY_ID }}" + export access_key_secret="${{ secrets.ALI_ACCESS_KEY_SECRET }}" + ./.github/scripts/alioss/run-int.sh + - name: Teardown Alioss Test Environment + if: always() + run: | + export access_key_id="${{ secrets.ALI_ACCESS_KEY_ID }}" + export access_key_secret="${{ secrets.ALI_ACCESS_KEY_SECRET }}" + export profile="${{ secrets.ALI_PROFILE_NAME }}" + ./.github/scripts/alioss/teardown.sh \ No newline at end of file From 34c50673c7ef7c4abb29abb719f49068742ed5c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Serdar=20=C3=96zer?= Date: Tue, 18 Nov 2025 13:00:48 +0100 Subject: [PATCH 02/14] fix: workflow name added, file name corrected. Readme updated --- ...ration copy.yml => alioss-integration.yml} | 2 + alioss/README.md | 42 +++++++++++++------ 2 files changed, 32 insertions(+), 12 deletions(-) rename .github/workflows/{alioss-integration copy.yml => alioss-integration.yml} (97%) diff --git a/.github/workflows/alioss-integration copy.yml b/.github/workflows/alioss-integration.yml similarity index 97% rename from .github/workflows/alioss-integration copy.yml rename to .github/workflows/alioss-integration.yml index 0759e47..96b7d70 100644 --- a/.github/workflows/alioss-integration copy.yml +++ b/.github/workflows/alioss-integration.yml @@ -1,3 +1,5 @@ +name: Alioss Integration Tests + on: push: pull_request: diff --git a/alioss/README.md b/alioss/README.md index 18c17fe..2d22a2f 100644 --- a/alioss/README.md +++ b/alioss/README.md @@ -1,7 +1,7 @@ # Ali Storage CLI The Ali Storage CLI is for uploading, fetching and deleting content to and from an Ali OSS. -It is highly inspired by the https://github.com/cloudfoundry/bosh-s3cli. +It is highly inspired by the [storage-cli/s3](https://github.com/cloudfoundry/storage-cli/blob/6058f516e9b81471b64a50b01e228158a05731f0/s3) ## Usage @@ -47,14 +47,32 @@ curl -X PUT -T path/to/file # Downloading a blob: curl -X GET ``` -## Running integration tests - -To run the integration tests: -- Export the following variables into your environment: - ``` bash - export ACCESS_KEY_ID= - export ACCESS_KEY_SECRET= - export ENDPOINT= - export BUCKET_NAME= - ``` -- go build && go test ./integration/... +## Running Tests + +### Unite Tests +```bash +go install github.com/onsi/ginkgo/v2/ginkgo +ginkgo --skip-package=integration --randomize-all --cover -v -r ./alioss/... +``` +### Integration Tests + +- To run the integration tests with your existing bucket: + 1. Export the following variables into your environment: + ``` bash + export ACCESS_KEY_ID= + export ACCESS_KEY_SECRET= + export ENDPOINT= + export BUCKET_NAME= + ``` + 1. go build -o ./alioss ./alioss && go test ./alioss/integration/... + +- To run it from scratch; create a new bucket, run tests, delete the bucket + 1. Create a user in your ali account and add policy `AliyunOSSFullAccess` or restrict the users with more granular policies like `oss:CreateBucket, oss:DeleteBucket` etc. + 1. Create access key for the user. + 1. Export `AccessKeyId` with command `export access_key_id=`. + 1. Export `AccessKeySecret` with command `export access_key_secret=`. + 1. Export `Profile` with command `export profile=`. + 1. Navigate to project's root folder. + 1. Run environment setup script to create container `/.github/scripts/alioss/setup.sh`. + 1. Run tests `/.github/scripts/alioss/run-int.sh`. + 1. Run environment teardown script to delete test resources `/.github/scripts/alioss/teardown.sh`. From 996a733c7f99a4337a3879a6bb9aff8e65214455 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Serdar=20=C3=96zer?= Date: Tue, 18 Nov 2025 13:50:14 +0100 Subject: [PATCH 03/14] fix: profile var is removed --- .github/scripts/alioss/setup.sh | 2 -- .github/scripts/alioss/teardown.sh | 2 -- .github/scripts/alioss/utils.sh | 3 +-- .github/workflows/alioss-integration.yml | 2 -- alioss/README.md | 1 - 5 files changed, 1 insertion(+), 9 deletions(-) diff --git a/.github/scripts/alioss/setup.sh b/.github/scripts/alioss/setup.sh index 4d29a9a..88d513a 100755 --- a/.github/scripts/alioss/setup.sh +++ b/.github/scripts/alioss/setup.sh @@ -8,7 +8,6 @@ repo_root="$(cd "${script_dir}/../../.." && pwd)" : "${access_key_id:?}" : "${access_key_secret:?}" -: "${profile:=integration-tests}" : "${test_name:=general}" : "${region:=cn-hangzhou}" @@ -16,7 +15,6 @@ repo_root="$(cd "${script_dir}/../../.." && pwd)" export ALI_ACCESS_KEY_ID="${access_key_id}" export ALI_ACCESS_KEY_SECRET="${secret_access_key}" export ALI_REGION="${region}" -export ALI_PROFILE="${profile}" diff --git a/.github/scripts/alioss/teardown.sh b/.github/scripts/alioss/teardown.sh index e9c0907..ba5d91b 100755 --- a/.github/scripts/alioss/teardown.sh +++ b/.github/scripts/alioss/teardown.sh @@ -7,14 +7,12 @@ repo_root="$(cd "${script_dir}/../../.." && pwd)" : "${access_key_id:?}" : "${access_key_secret:?}" -: "${profile:=integration-tests}" : "${test_name:=general}" : "${region:=cn-hangzhou}" export ALI_ACCESS_KEY_ID="${access_key_id}" export ALI_ACCESS_KEY_SECRET="${secret_access_key}" export ALI_REGION="${region}" -export ALI_PROFILE="${profile}" diff --git a/.github/scripts/alioss/utils.sh b/.github/scripts/alioss/utils.sh index 6149284..2f12066 100755 --- a/.github/scripts/alioss/utils.sh +++ b/.github/scripts/alioss/utils.sh @@ -31,8 +31,7 @@ function delete_bucket_name_file { function aliyun_configure { - aliyun configure set --profile "$ALI_PROFILE" \ - --access-key-id "$ALI_ACCESS_KEY_ID" \ + aliyun configure set --access-key-id "$ALI_ACCESS_KEY_ID" \ --access-key-secret "$ALI_ACCESS_KEY_SECRET" \ --region "$ALI_REGION" } diff --git a/.github/workflows/alioss-integration.yml b/.github/workflows/alioss-integration.yml index 96b7d70..a52301b 100644 --- a/.github/workflows/alioss-integration.yml +++ b/.github/workflows/alioss-integration.yml @@ -22,7 +22,6 @@ jobs: run: | export access_key_id="${{ secrets.ALI_ACCESS_KEY_ID }}" export access_key_secret="${{ secrets.ALI_ACCESS_KEY_SECRET }}" - export profile="${{ secrets.ALI_PROFILE_NAME }}" ./.github/scripts/alioss/setup.sh - name: Run Tests run: | @@ -34,5 +33,4 @@ jobs: run: | export access_key_id="${{ secrets.ALI_ACCESS_KEY_ID }}" export access_key_secret="${{ secrets.ALI_ACCESS_KEY_SECRET }}" - export profile="${{ secrets.ALI_PROFILE_NAME }}" ./.github/scripts/alioss/teardown.sh \ No newline at end of file diff --git a/alioss/README.md b/alioss/README.md index 2d22a2f..21f6070 100644 --- a/alioss/README.md +++ b/alioss/README.md @@ -71,7 +71,6 @@ ginkgo --skip-package=integration --randomize-all --cover -v -r ./alioss/... 1. Create access key for the user. 1. Export `AccessKeyId` with command `export access_key_id=`. 1. Export `AccessKeySecret` with command `export access_key_secret=`. - 1. Export `Profile` with command `export profile=`. 1. Navigate to project's root folder. 1. Run environment setup script to create container `/.github/scripts/alioss/setup.sh`. 1. Run tests `/.github/scripts/alioss/run-int.sh`. From 3f2383502e6fd45e87d3be716f5261369c4d90b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Serdar=20=C3=96zer?= Date: Tue, 18 Nov 2025 13:53:55 +0100 Subject: [PATCH 04/14] docs: typo corrected --- alioss/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/alioss/README.md b/alioss/README.md index 21f6070..9801f47 100644 --- a/alioss/README.md +++ b/alioss/README.md @@ -49,7 +49,7 @@ curl -X GET ``` ## Running Tests -### Unite Tests +### Unit Tests ```bash go install github.com/onsi/ginkgo/v2/ginkgo ginkgo --skip-package=integration --randomize-all --cover -v -r ./alioss/... From 0bc9458e7ccb3d2611f5bb0f8d476f1d8453a527 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Serdar=20=C3=96zer?= Date: Wed, 19 Nov 2025 14:56:20 +0100 Subject: [PATCH 05/14] feat: bucket exist function added --- .github/scripts/alioss/run-int.sh | 2 +- .github/scripts/alioss/setup.sh | 8 ++++---- .github/scripts/alioss/teardown.sh | 4 ++-- .github/scripts/alioss/utils.sh | 23 ++++++++++++++++++++--- 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/.github/scripts/alioss/run-int.sh b/.github/scripts/alioss/run-int.sh index ca78057..2acc353 100755 --- a/.github/scripts/alioss/run-int.sh +++ b/.github/scripts/alioss/run-int.sh @@ -7,7 +7,7 @@ repo_root="$(cd "${script_dir}/../../.." && pwd)" : "${access_key_id:?}" : "${access_key_secret:?}" : "${test_name:=general}" -: "${region:=cn-hangzhou}" +: "${region:=eu-central-1}" export ACCESS_KEY_ID="${access_key_id}" export ACCESS_KEY_SECRET="${secret_access_key}" diff --git a/.github/scripts/alioss/setup.sh b/.github/scripts/alioss/setup.sh index 88d513a..30a6d39 100755 --- a/.github/scripts/alioss/setup.sh +++ b/.github/scripts/alioss/setup.sh @@ -9,18 +9,18 @@ repo_root="$(cd "${script_dir}/../../.." && pwd)" : "${access_key_id:?}" : "${access_key_secret:?}" : "${test_name:=general}" -: "${region:=cn-hangzhou}" +: "${region:=eu-central-1}" export ALI_ACCESS_KEY_ID="${access_key_id}" -export ALI_ACCESS_KEY_SECRET="${secret_access_key}" +export ALI_ACCESS_KEY_SECRET="${access_key_secret}" export ALI_REGION="${region}" pushd "${script_dir}" source utils.sh - generate_bucket_name "${test_name}" - aliyun_configure + # generate_bucket_name "${test_name}" + # aliyun_configure create_bucket "${test_name}" popd diff --git a/.github/scripts/alioss/teardown.sh b/.github/scripts/alioss/teardown.sh index ba5d91b..1bfde48 100755 --- a/.github/scripts/alioss/teardown.sh +++ b/.github/scripts/alioss/teardown.sh @@ -8,10 +8,10 @@ repo_root="$(cd "${script_dir}/../../.." && pwd)" : "${access_key_id:?}" : "${access_key_secret:?}" : "${test_name:=general}" -: "${region:=cn-hangzhou}" +: "${region:=eu-central-1}" export ALI_ACCESS_KEY_ID="${access_key_id}" -export ALI_ACCESS_KEY_SECRET="${secret_access_key}" +export ALI_ACCESS_KEY_SECRET="${access_key_secret}" export ALI_REGION="${region}" diff --git a/.github/scripts/alioss/utils.sh b/.github/scripts/alioss/utils.sh index 2f12066..57f3ae2 100755 --- a/.github/scripts/alioss/utils.sh +++ b/.github/scripts/alioss/utils.sh @@ -36,15 +36,32 @@ function aliyun_configure { --region "$ALI_REGION" } - +function bucket_exists { + local bucket_name="$1" + if aliyun oss ls | grep -w "oss://${bucket_name}" > /dev/null 2>&1; then + return 0 + else + return 1 + fi +} function create_bucket { local bucket_name="$(read_bucket_name_from_file "$1")" - aliyun --profile "$ALI_PROFILE" oss mb "oss://$bucket_name" + + if bucket_exists "${bucket_name}"; then + echo "Bucket ${bucket_name} created successfully" + return 0 + else + echo "ERROR: Failed to create bucket ${bucket_name}" + return 1 + fi + } function delete_bucket { local bucket_name="$(read_bucket_name_from_file "$1")" - aliyun --profile "$ALI_PROFILE" oss rb "oss://$bucket_name" --force + local exists= bucket_exists "${bucket_name}" + + aliyun oss rm "oss://$bucket_name" } \ No newline at end of file From b8f2f3d73636bb60945382a43f7ae81d22f9aa99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Serdar=20=C3=96zer?= Date: Wed, 19 Nov 2025 15:56:19 +0100 Subject: [PATCH 06/14] feat: bucket delete check added --- .github/scripts/alioss/setup.sh | 4 ++-- .github/scripts/alioss/teardown.sh | 7 +++++-- .github/scripts/alioss/utils.sh | 10 +++++++--- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/.github/scripts/alioss/setup.sh b/.github/scripts/alioss/setup.sh index 30a6d39..c13308a 100755 --- a/.github/scripts/alioss/setup.sh +++ b/.github/scripts/alioss/setup.sh @@ -20,7 +20,7 @@ export ALI_REGION="${region}" pushd "${script_dir}" source utils.sh - # generate_bucket_name "${test_name}" - # aliyun_configure + generate_bucket_name "${test_name}" + aliyun_configure create_bucket "${test_name}" popd diff --git a/.github/scripts/alioss/teardown.sh b/.github/scripts/alioss/teardown.sh index 1bfde48..117daeb 100755 --- a/.github/scripts/alioss/teardown.sh +++ b/.github/scripts/alioss/teardown.sh @@ -19,6 +19,9 @@ export ALI_REGION="${region}" pushd "${script_dir}" source utils.sh aliyun_configure - delete_bucket "${test_name}" - delete_bucket_name_file "${test_name}" + if delete_bucket "${test_name}" ; then + echo "Failed to delete bucket" + else + delete_bucket_name_file "${test_name}" + fi popd diff --git a/.github/scripts/alioss/utils.sh b/.github/scripts/alioss/utils.sh index 57f3ae2..995df70 100755 --- a/.github/scripts/alioss/utils.sh +++ b/.github/scripts/alioss/utils.sh @@ -52,7 +52,7 @@ function create_bucket { echo "Bucket ${bucket_name} created successfully" return 0 else - echo "ERROR: Failed to create bucket ${bucket_name}" + echo "Failed to create bucket ${bucket_name}" return 1 fi @@ -61,7 +61,11 @@ function create_bucket { function delete_bucket { local bucket_name="$(read_bucket_name_from_file "$1")" - local exists= bucket_exists "${bucket_name}" + aliyun oss rm "oss://${bucket_name}" -b -r -f - aliyun oss rm "oss://$bucket_name" + if bucket_exists "${bucket_name}"; then + return 1 + else + return 0 + fi } \ No newline at end of file From 4965bbf6d5d6fc16f5d30f855e0463ba90c0206a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Serdar=20=C3=96zer?= Date: Wed, 19 Nov 2025 17:20:40 +0100 Subject: [PATCH 07/14] feat: integration tests are run successfully --- .github/scripts/alioss/run-int.sh | 5 ++--- .github/scripts/alioss/teardown.sh | 4 ++-- .github/scripts/alioss/utils.sh | 29 +++++++++++++++++++---------- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/.github/scripts/alioss/run-int.sh b/.github/scripts/alioss/run-int.sh index 2acc353..b44c5e4 100755 --- a/.github/scripts/alioss/run-int.sh +++ b/.github/scripts/alioss/run-int.sh @@ -10,7 +10,8 @@ repo_root="$(cd "${script_dir}/../../.." && pwd)" : "${region:=eu-central-1}" export ACCESS_KEY_ID="${access_key_id}" -export ACCESS_KEY_SECRET="${secret_access_key}" +export ACCESS_KEY_SECRET="${access_key_secret}" +export ENDPOINT="oss-"${region}".aliyuncs.com" pushd "${script_dir}" > /dev/null source utils.sh @@ -19,8 +20,6 @@ pushd "${script_dir}" > /dev/null export BUCKET_NAME="${bucket_name}" popd > /dev/null -export ENDPOINT="https://${BUCKET_NAME}.${region}.aliyuncs.com" - pushd "${repo_root}" > /dev/null echo -e "\n running tests with $(go version)..." ginkgo -r alioss/integration/ diff --git a/.github/scripts/alioss/teardown.sh b/.github/scripts/alioss/teardown.sh index 117daeb..8f1c5be 100755 --- a/.github/scripts/alioss/teardown.sh +++ b/.github/scripts/alioss/teardown.sh @@ -20,8 +20,8 @@ pushd "${script_dir}" source utils.sh aliyun_configure if delete_bucket "${test_name}" ; then - echo "Failed to delete bucket" + delete_bucket_name_file "${test_name}" else - delete_bucket_name_file "${test_name}" + exit 1 fi popd diff --git a/.github/scripts/alioss/utils.sh b/.github/scripts/alioss/utils.sh index 995df70..4e23bf5 100755 --- a/.github/scripts/alioss/utils.sh +++ b/.github/scripts/alioss/utils.sh @@ -47,13 +47,17 @@ function bucket_exists { function create_bucket { local bucket_name="$(read_bucket_name_from_file "$1")" - - if bucket_exists "${bucket_name}"; then + + if aliyun oss mb "oss://$bucket_name" 2>/dev/null; then echo "Bucket ${bucket_name} created successfully" - return 0 else - echo "Failed to create bucket ${bucket_name}" - return 1 + if bucket_exists "${bucket_name}"; then + echo "Bucket ${bucket_name} already exists" + return 0 + else + echo "Failed to create bucket ${bucket_name}" + return 1 + fi fi } @@ -61,11 +65,16 @@ function create_bucket { function delete_bucket { local bucket_name="$(read_bucket_name_from_file "$1")" - aliyun oss rm "oss://${bucket_name}" -b -r -f - - if bucket_exists "${bucket_name}"; then - return 1 + + if aliyun oss rm "oss://${bucket_name}" -b -r -f 2>/dev/null; then + echo "Bucket ${bucket_name} deleted successfully" else - return 0 + if bucket_exists "${bucket_name}"; then + echo "ERROR: Failed to delete bucket ${bucket_name}" + return 1 + else + echo "Bucket ${bucket_name} already deleted or doesn't exist" + fi fi + return 0 } \ No newline at end of file From a3c41065fb4c1fe6048daac2f67e683c563300b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Serdar=20=C3=96zer?= Date: Wed, 19 Nov 2025 17:44:57 +0100 Subject: [PATCH 08/14] feat: aliyun cli action added --- .github/workflows/alioss-integration.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/alioss-integration.yml b/.github/workflows/alioss-integration.yml index a52301b..30324ad 100644 --- a/.github/workflows/alioss-integration.yml +++ b/.github/workflows/alioss-integration.yml @@ -16,6 +16,8 @@ jobs: uses: actions/setup-go@v6 with: go-version-file: go.mod + - name: Set up Aliyun CLI + uses: aliyun/setup-aliyun-cli-action@v1 - name: Install Ginkgo run: go install github.com/onsi/ginkgo/v2/ginkgo@latest - name: Setup Alioss Test Environment From 479ec776afa651dc78796a00778b9d8988546432 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Serdar=20=C3=96zer?= Date: Wed, 19 Nov 2025 17:46:42 +0100 Subject: [PATCH 09/14] fix: environment tag removed from workflow --- .github/workflows/alioss-integration.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/alioss-integration.yml b/.github/workflows/alioss-integration.yml index 30324ad..06c51a8 100644 --- a/.github/workflows/alioss-integration.yml +++ b/.github/workflows/alioss-integration.yml @@ -8,7 +8,6 @@ jobs: alioss-general-integration-tests: name: Alioss Environment Integration Tests runs-on: ubuntu-latest - environment: alioss-integration steps: - name: Checkout code uses: actions/checkout@v5 From 9ae3090d41ecfc06b90f2e3071b92f9078dfd456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Serdar=20=C3=96zer?= Date: Wed, 19 Nov 2025 17:59:59 +0100 Subject: [PATCH 10/14] fix: pr path added for workflow --- .github/workflows/alioss-integration.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/alioss-integration.yml b/.github/workflows/alioss-integration.yml index 06c51a8..dec412d 100644 --- a/.github/workflows/alioss-integration.yml +++ b/.github/workflows/alioss-integration.yml @@ -1,12 +1,14 @@ name: Alioss Integration Tests on: - push: pull_request: + paths: + - ".github/workflows/alioss-integration.yml" + - "alioss/**" jobs: alioss-general-integration-tests: - name: Alioss Environment Integration Tests + name: Alioss General Integration Tests runs-on: ubuntu-latest steps: - name: Checkout code From a70fbf9ad3460d15eef612247d9983a6e7480709 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Serdar=20=C3=96zer?= Date: Fri, 21 Nov 2025 09:08:17 +0100 Subject: [PATCH 11/14] fix: copilot reviews are fixed --- .github/scripts/alioss/run-int.sh | 2 +- .github/scripts/alioss/teardown.sh | 2 +- .github/scripts/alioss/utils.sh | 2 +- alioss/README.md | 11 ++++++----- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/scripts/alioss/run-int.sh b/.github/scripts/alioss/run-int.sh index b44c5e4..140c7b3 100755 --- a/.github/scripts/alioss/run-int.sh +++ b/.github/scripts/alioss/run-int.sh @@ -11,7 +11,7 @@ repo_root="$(cd "${script_dir}/../../.." && pwd)" export ACCESS_KEY_ID="${access_key_id}" export ACCESS_KEY_SECRET="${access_key_secret}" -export ENDPOINT="oss-"${region}".aliyuncs.com" +export ENDPOINT="oss-${region}.aliyuncs.com" pushd "${script_dir}" > /dev/null source utils.sh diff --git a/.github/scripts/alioss/teardown.sh b/.github/scripts/alioss/teardown.sh index 8f1c5be..31c1c02 100755 --- a/.github/scripts/alioss/teardown.sh +++ b/.github/scripts/alioss/teardown.sh @@ -20,7 +20,7 @@ pushd "${script_dir}" source utils.sh aliyun_configure if delete_bucket "${test_name}" ; then - delete_bucket_name_file "${test_name}" + delete_bucket_name_file "${test_name}" else exit 1 fi diff --git a/.github/scripts/alioss/utils.sh b/.github/scripts/alioss/utils.sh index 4e23bf5..891aa2b 100755 --- a/.github/scripts/alioss/utils.sh +++ b/.github/scripts/alioss/utils.sh @@ -33,7 +33,7 @@ function delete_bucket_name_file { function aliyun_configure { aliyun configure set --access-key-id "$ALI_ACCESS_KEY_ID" \ --access-key-secret "$ALI_ACCESS_KEY_SECRET" \ - --region "$ALI_REGION" + --region "$ALI_REGION" } function bucket_exists { diff --git a/alioss/README.md b/alioss/README.md index 9801f47..cda9879 100644 --- a/alioss/README.md +++ b/alioss/README.md @@ -50,6 +50,7 @@ curl -X GET ## Running Tests ### Unit Tests +Navigate to project's root folder. And run the following commands. ```bash go install github.com/onsi/ginkgo/v2/ginkgo ginkgo --skip-package=integration --randomize-all --cover -v -r ./alioss/... @@ -67,11 +68,11 @@ ginkgo --skip-package=integration --randomize-all --cover -v -r ./alioss/... 1. go build -o ./alioss ./alioss && go test ./alioss/integration/... - To run it from scratch; create a new bucket, run tests, delete the bucket - 1. Create a user in your ali account and add policy `AliyunOSSFullAccess` or restrict the users with more granular policies like `oss:CreateBucket, oss:DeleteBucket` etc. + 1. Create a user in your ali account and add policy `AliyunOSSFullAccess`, or restrict the users with more granular policies like `oss:CreateBucket`, `oss:DeleteBucket` etc. 1. Create access key for the user. 1. Export `AccessKeyId` with command `export access_key_id=`. - 1. Export `AccessKeySecret` with command `export access_key_secret=`. + 1. Export `AccessKeySecret` with command `export access_key_secret=`. 1. Navigate to project's root folder. - 1. Run environment setup script to create container `/.github/scripts/alioss/setup.sh`. - 1. Run tests `/.github/scripts/alioss/run-int.sh`. - 1. Run environment teardown script to delete test resources `/.github/scripts/alioss/teardown.sh`. + 1. Run environment setup script to create bucket `./.github/scripts/alioss/setup.sh`. + 1. Run tests `./.github/scripts/alioss/run-int.sh`. + 1. Run environment teardown script to delete test resources `./.github/scripts/alioss/teardown.sh`. From 9aaa13a5f7ec6fb2b7724f754b02a891eaeb7e89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Serdar=20=C3=96zer?= Date: Fri, 21 Nov 2025 09:19:57 +0100 Subject: [PATCH 12/14] docs: run location clarified --- alioss/README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/alioss/README.md b/alioss/README.md index cda9879..24a3c21 100644 --- a/alioss/README.md +++ b/alioss/README.md @@ -53,6 +53,7 @@ curl -X GET Navigate to project's root folder. And run the following commands. ```bash go install github.com/onsi/ginkgo/v2/ginkgo + ginkgo --skip-package=integration --randomize-all --cover -v -r ./alioss/... ``` ### Integration Tests @@ -65,8 +66,10 @@ ginkgo --skip-package=integration --randomize-all --cover -v -r ./alioss/... export ENDPOINT= export BUCKET_NAME= ``` - 1. go build -o ./alioss ./alioss && go test ./alioss/integration/... - + 1. Navigate to project's root folder and run the command below: + ``` bash + go build -o ./alioss ./alioss && go test ./alioss/integration/... + ``` - To run it from scratch; create a new bucket, run tests, delete the bucket 1. Create a user in your ali account and add policy `AliyunOSSFullAccess`, or restrict the users with more granular policies like `oss:CreateBucket`, `oss:DeleteBucket` etc. 1. Create access key for the user. From a4a3cba6bf21f241abb99b239cd52128a00e4100 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Serdar=20=C3=96zer?= Date: Fri, 21 Nov 2025 09:24:20 +0100 Subject: [PATCH 13/14] docs: run location for unit tests added --- alioss/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/alioss/README.md b/alioss/README.md index 24a3c21..a8f401a 100644 --- a/alioss/README.md +++ b/alioss/README.md @@ -50,7 +50,8 @@ curl -X GET ## Running Tests ### Unit Tests -Navigate to project's root folder. And run the following commands. +**Note:** Run the following commands from the repository root directory. + ```bash go install github.com/onsi/ginkgo/v2/ginkgo From 40fb65a748b472a381800524dd76aa08e1575952 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Serdar=20=C3=96zer?= Date: Fri, 21 Nov 2025 13:38:24 +0100 Subject: [PATCH 14/14] feat: push main and manual trigger are added --- .github/workflows/alioss-integration.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/alioss-integration.yml b/.github/workflows/alioss-integration.yml index dec412d..928bc6d 100644 --- a/.github/workflows/alioss-integration.yml +++ b/.github/workflows/alioss-integration.yml @@ -1,11 +1,14 @@ name: Alioss Integration Tests on: + workflow_dispatch: pull_request: paths: - ".github/workflows/alioss-integration.yml" - "alioss/**" - + push: + branches: + - main jobs: alioss-general-integration-tests: name: Alioss General Integration Tests