diff --git a/.circleci/config.yml b/.circleci/config.yml index 1142aa9..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 diff --git a/.github/workflows/build_and_test.yaml b/.github/workflows/build_and_test.yaml new file mode 100644 index 0000000..75693a0 --- /dev/null +++ b/.github/workflows/build_and_test.yaml @@ -0,0 +1,17 @@ +name: CI + +on: + 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/ diff --git a/CHANGES.md b/CHANGES.md index fa4ef40..3105736 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,23 @@ # Change Log +## v2.3.0 + +* Switching to GH actions + + Contributed by Bradley Bishop (Encore Technologies). + +## 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. + + Contributed by Bradley Bishop (Encore Technologies). + ## v2.1.0 * Added new `project` option that replaces `boltdir`. diff --git a/actions/lib/bolt.py b/actions/lib/bolt.py index 52778aa..dde76e5 100644 --- a/actions/lib/bolt.py +++ b/actions/lib/bolt.py @@ -164,6 +164,12 @@ def build_options_args(self, **kwargs): args.append(str(v)) return options, args + def check_byte_string(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 +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_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/pack.yaml b/pack.yaml index fe21aae..3ab2f7a 100644 --- a/pack.yaml +++ b/pack.yaml @@ -8,7 +8,7 @@ keywords: - remote execution - configuration management - cfg management -version: 2.1.0 +version: 2.3.0 author: Encore Technologies email: code@encore.tech python_versions: 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):