From a0fcb74c0971b69e223902d1aeb9f8ac58532668 Mon Sep 17 00:00:00 2001 From: Bradley Bishop Date: Wed, 10 Mar 2021 11:33:00 -0500 Subject: [PATCH 01/11] Adding method to convert byte strings --- actions/lib/bolt.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/actions/lib/bolt.py b/actions/lib/bolt.py index 52778aa..69dbc79 100644 --- a/actions/lib/bolt.py +++ b/actions/lib/bolt.py @@ -164,6 +164,13 @@ def build_options_args(self, **kwargs): args.append(str(v)) return options, args + + def check_byte_strig(self, string): + if isinstance(string, bytes): + string = string.decode("utf-8") + + return string + def execute(self, cmd, sub_command, options, args, env, cwd, format): full_cmd = [cmd] + sub_command.split(' ') + options + args process = subprocess.Popen(full_cmd, @@ -172,6 +179,8 @@ def execute(self, cmd, sub_command, options, args, env, cwd, format): env=env, cwd=cwd) stdout, stderr = process.communicate() + stdout = self.check_byte_strig(stdout) + stderr = self.check_byte_strig(stderr) # only try to parse JSON when the requested output format is JSON # if it's 'human' format, then skip JSON parsing to avoid the unecessary # exceptions From e8765fcde083130ada82a72bcc53c77e205104b9 Mon Sep 17 00:00:00 2001 From: Bradley Bishop Date: Sun, 6 Jun 2021 22:56:59 -0400 Subject: [PATCH 02/11] Fixing lint issues. --- actions/lib/bolt.py | 1 - 1 file changed, 1 deletion(-) diff --git a/actions/lib/bolt.py b/actions/lib/bolt.py index 69dbc79..2a567e9 100644 --- a/actions/lib/bolt.py +++ b/actions/lib/bolt.py @@ -164,7 +164,6 @@ def build_options_args(self, **kwargs): args.append(str(v)) return options, args - def check_byte_strig(self, string): if isinstance(string, bytes): string = string.decode("utf-8") From 5491ca37a29fceef089ce85f505823206f82db6d Mon Sep 17 00:00:00 2001 From: Bradley Bishop Date: Sun, 6 Jun 2021 23:44:21 -0400 Subject: [PATCH 03/11] Fixed syntax issue. Added tests. --- actions/lib/bolt.py | 6 +++--- tests/test_action_lib_bolt.py | 10 ++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/actions/lib/bolt.py b/actions/lib/bolt.py index 2a567e9..dde76e5 100644 --- a/actions/lib/bolt.py +++ b/actions/lib/bolt.py @@ -164,7 +164,7 @@ def build_options_args(self, **kwargs): args.append(str(v)) return options, args - def check_byte_strig(self, string): + def check_byte_string(self, string): if isinstance(string, bytes): string = string.decode("utf-8") @@ -178,8 +178,8 @@ def execute(self, cmd, sub_command, options, args, env, cwd, format): env=env, cwd=cwd) stdout, stderr = process.communicate() - stdout = self.check_byte_strig(stdout) - stderr = self.check_byte_strig(stderr) + stdout = self.check_byte_string(stdout) + stderr = self.check_byte_string(stderr) # only try to parse JSON when the requested output format is JSON # if it's 'human' format, then skip JSON parsing to avoid the unecessary # exceptions diff --git a/tests/test_action_lib_bolt.py b/tests/test_action_lib_bolt.py index a1640c9..15e4416 100644 --- a/tests/test_action_lib_bolt.py +++ b/tests/test_action_lib_bolt.py @@ -365,6 +365,16 @@ def test_build_options_args_ensure_unknown_args_cast_to_strings(self): self.assertEquals(args, ['True', '123']) self.assertEquals(options, []) + def test_check_byte_string(self): + action = self.get_action_instance({}) + result = action.check_byte_string(b'test') + self.assertEquals(result, 'test') + + def test_check_byte_string_no_bytes(self): + action = self.get_action_instance({}) + result = action.check_byte_string('test') + self.assertEquals(result, 'test') + @mock.patch('lib.bolt.sys') @mock.patch('subprocess.Popen') def test_execute(self, mock_popen, mock_sys): From 820d3b20aba6c496245438d171b596ba1db65bd5 Mon Sep 17 00:00:00 2001 From: Bradley Bishop Date: Mon, 7 Jun 2021 00:02:05 -0400 Subject: [PATCH 04/11] Added Pack updates . --- CHANGES.md | 6 ++++++ pack.yaml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index fa4ef40..6f8feb8 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,11 @@ # Change Log +## v2.2.0 + +* Added Python 3 fix for converting byte strings. + + Contributed by Bradley Bishop (Encore Technologies). + ## v2.1.0 * Added new `project` option that replaces `boltdir`. diff --git a/pack.yaml b/pack.yaml index fe21aae..2969269 100644 --- a/pack.yaml +++ b/pack.yaml @@ -8,7 +8,7 @@ keywords: - remote execution - configuration management - cfg management -version: 2.1.0 +version: 2.2.0 author: Encore Technologies email: code@encore.tech python_versions: From 28385d063859fb9ee9bc16aaa9fc6fe108d87516 Mon Sep 17 00:00:00 2001 From: Alex Chrystal Date: Thu, 24 Mar 2022 11:20:13 -0400 Subject: [PATCH 05/11] updating circleci url --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1142aa9..2dc1a14 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -27,7 +27,7 @@ jobs: # doesn't declare support for Python 3 shell: /bin/bash command: | - git clone -b master git://github.com/stackstorm-exchange/ci.git ~/ci + git clone -b master git@github.com:StackStorm-Exchange/ci.git ~/ci ~/ci/.circle/dependencies ; ~/ci/.circle/exit_on_py3_checks $? - run: name: Run tests (Python 3.6) From 0c5dea5e9c563cd88c43dc4eff279c322c789a71 Mon Sep 17 00:00:00 2001 From: Alex Chrystal Date: Thu, 24 Mar 2022 15:20:52 -0400 Subject: [PATCH 06/11] adding to changelog and bumping pack version --- CHANGES.md | 6 ++++++ pack.yaml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 6f8feb8..8484cf6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,11 @@ # Change Log +## v2.2.1 + +* Switches stackstorm-ci url to an ssh url + + Contributed by Alex Chrystal (Encore Technologies). + ## v2.2.0 * Added Python 3 fix for converting byte strings. diff --git a/pack.yaml b/pack.yaml index 2969269..0b92d3f 100644 --- a/pack.yaml +++ b/pack.yaml @@ -8,7 +8,7 @@ keywords: - remote execution - configuration management - cfg management -version: 2.2.0 +version: 2.2.1 author: Encore Technologies email: code@encore.tech python_versions: From 5d6c376bc02a61dbc4f2eaaaa6ea4eb75785978c Mon Sep 17 00:00:00 2001 From: Bradley Bishop Date: Tue, 5 Apr 2022 10:35:14 -0400 Subject: [PATCH 07/11] Adding GH actions files --- .github/workflows/build_and_test.yaml | 18 ++++++++++++++++++ .github/workflows/release.yaml | 25 +++++++++++++++++++++++++ .gitignore | 3 +++ 3 files changed, 46 insertions(+) create mode 100644 .github/workflows/build_and_test.yaml create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/build_and_test.yaml b/.github/workflows/build_and_test.yaml new file mode 100644 index 0000000..9c8aca8 --- /dev/null +++ b/.github/workflows/build_and_test.yaml @@ -0,0 +1,18 @@ +name: CI + +on: + workflow_dispatch: + pull_request: + schedule: + # NOTE: We run this weekly at 1 am UTC on every Saturday + - cron: '0 1 * * 6' + +jobs: + # This is mirrored in the release workflow. + build_and_test: + name: 'Build and Test' + uses: StackStorm-Exchange/ci/.github/workflows/pack-build_and_test.yaml@master + with: + enable-common-libs: true + #apt-cache-version: v0 + #py-cache-version: v0 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..9896772 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,25 @@ +name: Release + +on: + push: + branches: + # the default branch + - master + +permissions: + contents: write + +jobs: + # This mirrors build_and_test workflow + build_and_test: + name: 'Build and Test' + uses: StackStorm-Exchange/ci/.github/workflows/pack-build_and_test.yaml@master + with: + enable-common-libs: true + #apt-cache-version: v0 + #py-cache-version: v0 + + tag_release: + needs: build_and_test + name: Tag Release + uses: StackStorm-Exchange/ci/.github/workflows/pack-tag_release.yaml@master diff --git a/.gitignore b/.gitignore index 4bccdb2..1e6cc0d 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,9 @@ __pycache__/ # C extensions *.so +# Ignore useless mac file +.DS_Store + # Distribution / packaging .Python env/ From de83250109d592709ef70cb01fd8ac16572858de Mon Sep 17 00:00:00 2001 From: Bradley Bishop Date: Tue, 5 Apr 2022 10:41:51 -0400 Subject: [PATCH 08/11] disabling circleci workflows --- .circleci/config.yml | 104 +++---------------------------------------- 1 file changed, 5 insertions(+), 99 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2dc1a14..4664451 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,110 +1,16 @@ version: 2 jobs: - build_and_test_python36: + circleci_is_disabled_job: docker: - - image: circleci/python:3.6 - - image: rabbitmq:3 - - image: mongo:3.4 - - working_directory: ~/repo - - environment: - VIRTUALENV_DIR: "~/virtualenv" - # Don't install various StackStorm dependencies which are already - # installed by CI again in the various check scripts - ST2_INSTALL_DEPS: "0" - + - image: cimg/base:stable steps: - - checkout - - restore_cache: - key: v1-dependency-cache-py36-{{ checksum "requirements.txt" }} - - run: - name: Download dependencies - # NOTE: We don't want to use default "-e" option because this means - # step will fail immediately on one of the commands failures and we - # can't intercept the error and cause non-fatal exit in case pack - # doesn't declare support for Python 3 - shell: /bin/bash - command: | - git clone -b master git@github.com:StackStorm-Exchange/ci.git ~/ci - ~/ci/.circle/dependencies ; ~/ci/.circle/exit_on_py3_checks $? - run: - name: Run tests (Python 3.6) - # NOTE: We don't want to use default "-e" option because this means - # step will fail immediately on one of the commands failures and we - # can't intercept the error and cause non-fatal exit in case pack - # doesn't declare support for Python 3 shell: /bin/bash - command: ~/ci/.circle/test ; ~/ci/.circle/exit_on_py3_checks $? - - save_cache: - key: v1-dependency-cache-py36-{{ checksum "requirements.txt" }} - paths: - - ~/.cache/pip - - ~/.apt-cache - # NOTE: We use virtualenv files from Python 3.6 step in "deploy" job so we - # only persist paths from this job - - persist_to_workspace: - root: / - paths: - - home/circleci/ci - - home/circleci/virtualenv - - tmp/st2 - - home/circleci/repo - - home/circleci/.gitconfig - - - deploy: - docker: - - image: circleci/python:3.6 - - working_directory: ~/repo - - environment: - VIRTUALENV_DIR: "~/virtualenv" - - steps: - - checkout - - restore_cache: - key: v1-dependency-cache-py36-{{ checksum "requirements.txt" }} - - attach_workspace: - at: / - - run: - name: Install dependencies - command: | - sudo apt-get update - sudo apt -y install gmic optipng - ~/ci/.circle/install_gh - - run: - # NOTE: We try to retry the script up to 5 times if it fails. The command could fail due - # to the race (e.g. we try to push changes to index, but index has been updated by some - # other pack in the mean time) - name: Update exchange.stackstorm.org - command: ~/ci/.circle/retry_on_failure.sh ~/ci/.circle/deployment + command: echo CircleCI disabled on StackStorm-Exchange workflows: version: 2 - # Workflow which runs on each push - build_test_deploy_on_push: - jobs: - - build_and_test_python36 - - deploy: - requires: - - build_and_test_python36 - filters: - branches: - only: master - build_test_weekly: + circleci_is_disabled: jobs: - - build_and_test_python36 - # Workflow which runs nightly - note we don't perform deploy job on nightly - # build - triggers: - # Run nightly build for the pack - - schedule: - # NOTE: We run it at 1 am UTC on every Saturday - cron: "0 1 * * 6" - filters: - branches: - only: - - master + - circleci_is_disabled_job From 5f7d9500e1eccef3ed5d395677315c57af38797e Mon Sep 17 00:00:00 2001 From: Bradley Bishop Date: Tue, 5 Apr 2022 10:48:21 -0400 Subject: [PATCH 09/11] Updated changelog and pack version --- CHANGES.md | 6 ++++++ pack.yaml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 8484cf6..f1273eb 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,11 @@ # Change Log +## v2.3.0 + +* Switching to GH actions + + Contributed by Alex Chrystal (Encore Technologies). + ## v2.2.1 * Switches stackstorm-ci url to an ssh url diff --git a/pack.yaml b/pack.yaml index 0b92d3f..3ab2f7a 100644 --- a/pack.yaml +++ b/pack.yaml @@ -8,7 +8,7 @@ keywords: - remote execution - configuration management - cfg management -version: 2.2.1 +version: 2.3.0 author: Encore Technologies email: code@encore.tech python_versions: From 54527cf6239ef835125d6b597b14b602d127ea40 Mon Sep 17 00:00:00 2001 From: Bradley Bishop Date: Tue, 5 Apr 2022 12:15:21 -0400 Subject: [PATCH 10/11] fixing syntax --- .github/workflows/build_and_test.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build_and_test.yaml b/.github/workflows/build_and_test.yaml index 9c8aca8..75693a0 100644 --- a/.github/workflows/build_and_test.yaml +++ b/.github/workflows/build_and_test.yaml @@ -1,7 +1,6 @@ name: CI on: - workflow_dispatch: pull_request: schedule: # NOTE: We run this weekly at 1 am UTC on every Saturday From 6fc9e088c5288cd3ce5f4ff0f3cec11e306ee37e Mon Sep 17 00:00:00 2001 From: Bradley Bishop Date: Thu, 14 Apr 2022 00:06:08 -0400 Subject: [PATCH 11/11] Updating changelog --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index f1273eb..3105736 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,7 +4,7 @@ * Switching to GH actions - Contributed by Alex Chrystal (Encore Technologies). + Contributed by Bradley Bishop (Encore Technologies). ## v2.2.1