diff --git a/.circle/Makefile b/.circle/Makefile index 315c7d49..e2b74bf3 100644 --- a/.circle/Makefile +++ b/.circle/Makefile @@ -1,9 +1,13 @@ ROOT_DIR ?= $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) -NUM_CHANGED_FILES := $(shell $(CI_DIR)/utils/git-changes files | wc -w) -NUM_CHANGED_PY := $(shell $(CI_DIR)/utils/git-changes py | wc -w) -NUM_CHANGED_YAML := $(shell $(CI_DIR)/utils/git-changes yaml | wc -w) -NUM_CHANGED_JSON := $(shell $(CI_DIR)/utils/git-changes json | wc -w) -CHANGED_DIRECTORIES := $(shell $(CI_DIR)/utils/git-changes directories) +#NUM_CHANGED_PY := $(shell $(CI_DIR)/utils/git-changes py | wc -w) +#NUM_CHANGED_YAML := $(shell $(CI_DIR)/utils/git-changes yaml | wc -w) +#NUM_CHANGED_JSON := $(shell $(CI_DIR)/utils/git-changes json | wc -w) +#CHANGED_DIRECTORIES := $(shell $(CI_DIR)/utils/git-changes directories) +NUM_CHANGED_FILES := $(shell /home/runner/work/_actions/lm-ydubler/ci/gha/utils/git-changes-files | wc -w) +NUM_CHANGED_PY := $(shell /home/runner/work/_actions/lm-ydubler/ci/gha/utils/git-changes-py | wc -w) +NUM_CHANGED_YAML := $(shell /home/runner/work/_actions/lm-ydubler/ci/gha/utils/git-changes-yaml | wc -w) +NUM_CHANGED_JSON := $(shell /home/runner/work/_actions/lm-ydubler/ci/gha/utils/git-changes-json | wc -w) +CHANGED_DIRECTORIES := $(shell /home/runner/work/_actions/lm-ydubler/ci/gha/utils/git-changes-directories) VIRTUALENV_DIR ?= virtualenv ST2_REPO_PATH ?= /tmp/st2 ST2_REPO_BRANCH ?= master @@ -293,8 +297,8 @@ requirements-ci: @echo "==================== requirements-ci ====================" @echo . $(VIRTUALENV_DIR)/bin/activate && $(VIRTUALENV_DIR)/bin/pip install --upgrade "pip==20.3.3" - . $(VIRTUALENV_DIR)/bin/activate && $(VIRTUALENV_DIR)/bin/pip install --cache-dir $(HOME)/.pip-cache -q -r $(CI_DIR)/.circle/requirements-dev.txt - . $(VIRTUALENV_DIR)/bin/activate && $(VIRTUALENV_DIR)/bin/pip install --cache-dir $(HOME)/.pip-cache -q -r $(CI_DIR)/.circle/requirements-pack-tests.txt + . $(VIRTUALENV_DIR)/bin/activate && $(VIRTUALENV_DIR)/bin/pip install --cache-dir $(HOME)/.pip-cache -q -r /home/runner/work/_actions/lm-ydubler/ci/gha/.circle/requirements-dev.txt + . $(VIRTUALENV_DIR)/bin/activate && $(VIRTUALENV_DIR)/bin/pip install --cache-dir $(HOME)/.pip-cache -q -r /home/runner/work/_actions/lm-ydubler/ci/gha/.circle/requirements-pack-tests.txt .PHONY: virtualenv virtualenv: $(VIRTUALENV_DIR)/bin/activate diff --git a/gha/apt-dependencies/action.yaml b/gha/apt-dependencies/action.yaml index cdd88782..4c82bf38 100644 --- a/gha/apt-dependencies/action.yaml +++ b/gha/apt-dependencies/action.yaml @@ -15,6 +15,7 @@ runs: - name: Create a directory for debian packages so we can cache it # this is what we did on CircleCI. Not sure if it'll work on GHA + shell: bash run: > sudo rm -rf /var/cache/apt/archives && sudo ln -s ~/apt_cache /var/cache/apt/archives @@ -29,22 +30,25 @@ runs: with: path: | ~/apt_cache - key: ${{ runner.os }}-apt-${{ input.cache-version }}-${{ hashFiles(github.action_path + '/apt-packages.txt') }} + key: ${{ runner.os }}-apt-${{ inputs.cache-version }}-${{ hashFiles(format('{0}{1}', github.action_path, '/apt-packages.txt')) }} restore-keys: | - ${{ runner.os }}-apt-${{ input.cache-version }}- + ${{ runner.os }}-apt-${{ inputs.cache-version }}- - name: Install APT Dependencies + shell: bash env: CACHE_HIT: ${{steps.cache-apt-deps.outputs.cache-hit}} - APT_PACKAGES_FILE_PATH: ${{github.action_path + '/apt-packages.txt'}} + APT_PACKAGES_FILE_PATH: ${{ format('{0}{1}', github.action_path, '/apt-packages.txt') }} run: | - if [[ "$CACHE_HIT" != 'true' ]]; then + if [[ "${CACHE_HIT}" != 'true' ]]; then sudo apt-get -y update fi APT_PACKAGES=$(grep -v '^#' "${APT_PACKAGES_FILE_PATH}" | xargs echo -n) + echo APT_PACKAGES_FILE_PATH=${APT_PACKAGES_FILE_PATH} sudo apt-get -y install ${APT_PACKAGES} - name: Print versions + shell: bash run: | set -ex jq --version diff --git a/gha/checkout/action.yaml b/gha/checkout/action.yaml index 2c64bd3b..3587ab74 100644 --- a/gha/checkout/action.yaml +++ b/gha/checkout/action.yaml @@ -23,6 +23,7 @@ runs: using: "composite" steps: - name: Configure git user + shell: bash env: GIT_USER_NAME: "${{ inputs.git_user_name }}" GIT_USER_EMAIL: "${{ inputs.git_user_email }}" @@ -32,8 +33,9 @@ runs: - name: Checkout pack repo uses: actions/checkout@v2 + with: path: pack - depth: 1 + fetch-depth: 1 - name: Checkout st2 repo # so other scripts can reference StackStorm Python code @@ -42,7 +44,7 @@ runs: repository: StackStorm/st2 ref: ${{ inputs.st2_branch }} path: st2 - depth: 1 + fetch-depth: 1 - name: Checkout lint-configs repo uses: actions/checkout@v2 @@ -50,4 +52,4 @@ runs: repository: StackStorm/lint-configs ref: ${{ inputs.lint_configs_branch }} path: lint-configs - depth: 1 + fetch-depth: 1 diff --git a/gha/py-dependencies/action.yaml b/gha/py-dependencies/action.yaml index 73b6689d..2b186391 100644 --- a/gha/py-dependencies/action.yaml +++ b/gha/py-dependencies/action.yaml @@ -7,10 +7,12 @@ description: | StackStorm-Exchange/ci/gha/apt-dependencies. author: StackStorm + inputs: python-version: required: true description: Which python version we should install + default: "3.6" cache-version: required: false default: "v0" @@ -24,10 +26,10 @@ runs: using: "composite" steps: - - name: 'Set up Python (${{ input.python-version }})' + - name: 'Set up Python (${{ inputs.python-version }})' uses: actions/setup-python@v2 with: - python-version: '${{ input.python-version }}' + python-version: '${{ inputs.python-version }}' - name: Cache Python Dependencies uses: actions/cache@v2 @@ -35,17 +37,19 @@ runs: path: | ~/.cache/pip ~/virtualenv - key: ${{ runner.os }}-python-${{ input.python-version }}-${{ input.cache-version }}-${{ hashFiles('requirements.txt') }} + key: ${{ runner.os }}-python-${{ inputs.python-version }}-${{ inputs.cache-version }}-${{ hashFiles('requirements.txt') }} restore-keys: | - ${{ runner.os }}-python-${{ input.python-version }}-${{ input.cache-version }}- + ${{ runner.os }}-python-${{ inputs.python-version }}-${{ inputs.cache-version }}- - - name: Install virtualenv - # this should run in the st2 checkout - working-directory: st2 - run: | - ./scripts/github/install-virtualenv.sh +# - name: Install virtualenv +# shell: bash +# # this should run in the st2 checkout +# working-directory: st2 +# run: | +# ./scripts/github/install-virtualenv.sh - name: Create ~/virtualenv + shell: bash id: virtualenv # this should run in the st2 checkout working-directory: st2 @@ -55,27 +59,31 @@ runs: ./scripts/github/install-virtualenv.sh PIP_VERSION=$(grep '^PIP_VERSION' Makefile | awk '{print $3}') echo "::set-output name=pip-version::${PIP_VERSION}" - ${VIRTUALENV_DIR}/bin/pip install -U "pip==${PIP_VERSION}" setuptools + ${{env.VIRTUALENV_DIR}}/bin/pip install -U "pip==${PIP_VERSION}" setuptools - name: Install StackStorm requirements # this should run in the st2 checkout + shell: bash working-directory: st2 env: VIRTUALENV_DIR: "~/virtualenv" run: | - ${VIRTUALENV_DIR}/bin/pip install -r requirements.txt + ${{env.VIRTUALENV_DIR}}/bin/pip install -r requirements.txt - name: Install runners + shell: bash env: VIRTUALENV_DIR: "~/virtualenv" ACTION_PATH: ${{ github.action_path }} ST2_REPO_PATH: st2 + CI_DIR: ${{ format('{0}{1}', github.action_path, '/../..') }} # TODO: This Makefile has CircleCI assumptions run: | - cp ${ACTION_PATH}/../../.circle/Makefile . + cp ${{env.ACTION_PATH}}/../../.circle/Makefile . make requirements-ci .install-runners - name: Install pack requirements + shell: bash working-directory: pack env: VIRTUALENV_DIR: "~/virtualenv" @@ -84,19 +92,20 @@ runs: run: | if [[ -f "${PACK_REQUIREMENTS_FILE}" ]]; then echo "Installing pack requirements from ${PACK_REQUIREMENTS_FILE}" - ${VIRTUALENV_DIR}/bin/pip install -r "${PACK_REQUIREMENTS_FILE}" + ${{env.VIRTUALENV_DIR}}/bin/pip install -r "${PACK_REQUIREMENTS_FILE}" fi if [[ -f "${PACK_TESTS_REQUIREMENTS_FILE}" ]]; then echo "Installing pack tests requirements from ${PACK_TESTS_REQUIREMENTS_FILE}" - ${VIRTUALENV_DIR}/bin/pip install -r "${PACK_TESTS_REQUIREMENTS_FILE}" + ${{env.VIRTUALENV_DIR}}/bin/pip install -r "${PACK_TESTS_REQUIREMENTS_FILE}" fi - name: Print versions + shell: bash env: VIRTUALENV_DIR: "~/virtualenv" run: | set -ex - source ${VIRTUALENV_DIR}/activate + source ${{env.VIRTUALENV_DIR}}/bin/activate python3 --version pip --version virtualenv --version diff --git a/gha/test/action.yaml b/gha/test/action.yaml index e8772d0e..c58322ac 100644 --- a/gha/test/action.yaml +++ b/gha/test/action.yaml @@ -24,27 +24,51 @@ runs: using: "composite" steps: +# - name: Get Pack Name (original) +# shell: bash +# id: pack-name +# env: +# VIRTUALENV_DIR: "~/virtualenv" +# ACTION_PATH: ${{ github.action_path }} +# run: | +# env +# export PACK_NAME=$(${{env.VIRTUALENV_DIR}}/bin/python ${ACTION_PATH}/../../.circle/validate.py "${GITHUB_REPOSITORY##*/}" pack.yaml) +# if [[ -z "${PACK_NAME}" ]]; then +# echo "Unable to retrieve pack name." +# exit 1 +# fi +# echo "::set-output name=pack-name::${PACK_NAME}" + - name: Get Pack Name + shell: bash id: pack-name env: VIRTUALENV_DIR: "~/virtualenv" ACTION_PATH: ${{ github.action_path }} run: | - export PACK_NAME=$(${VIRTUALENV_DIR}/bin/python ${ACTION_PATH}/../../.circle/validate.py "${GITHUB_REPOSITORY##*/}" pack.yaml) + echo -e '\n\n/home/runner/work/logicmonitor-stackstorm-pack/ \n\n' + ls /home/runner/work/logicmonitor-stackstorm-pack/ + echo -e '\n\n/home/runner/work/lm-ydubler/logicmonitor-stackstorm-pack \n\n' + ls /home/runner/work/logicmonitor-stackstorm-pack/logicmonitor-stackstorm-pack/ + echo -e '\n\n/home/runner/work/logicmonitor-stackstorm-pack/logicmonitor-stackstorm-pack/pack/ \n\n' + ls /home/runner/work/logicmonitor-stackstorm-pack/logicmonitor-stackstorm-pack/pack/ + echo -e '\n\n' + export PACK_NAME=$(${{env.VIRTUALENV_DIR}}/bin/python ${ACTION_PATH}/../../.circle/validate.py "lm-ydubler/logicmonitor-stackstorm-pack" "/home/runner/work/logicmonitor-stackstorm-pack/logicmonitor-stackstorm-pack/pack/pack.yaml") if [[ -z "${PACK_NAME}" ]]; then echo "Unable to retrieve pack name." exit 1 fi echo "::set-output name=pack-name::${PACK_NAME}" - - name: + - name: Unsure + shell: bash env: VIRTUALENV_DIR: "~/virtualenv" FORCE_CHECK_ALL_FILES: true if on default branch - ROOT_DIR: pack directory - CI_DIR: ${{ github.action_path + "/../.." }} + ROOT_DIR: "/home/runner/work/logicmonitor-stackstorm-pack/logicmonitor-stackstorm-pack/" + CI_DIR: ${{ format('{0}{1}', github.action_path, '/../..') }} ST2_REPO_PATH: st2 directory - ENABLE_COMMON_LIBS: ${{ input.enable-common-libs }} + ENABLE_COMMON_LIBS: ${{ inputs.enable-common-libs }} # TODO: This Makefile has CircleCI assumptions run: | if [[ "true" == "${ENABLE_COMMON_LIBS}" ]]; then @@ -54,6 +78,6 @@ runs: export ST2_CONFIG_FILE=${CI_DIR}/conf/st2.tests.conf fi cp ${CI_DIR}/.circle/Makefile . - make -C "${ROOT_DIR}" all-ci + make -C "${{env.ROOT_DIR}}" all-ci