From 8a031c06ca971981969d0d156badff328aa07b66 Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Tue, 4 Oct 2022 21:27:02 -0500 Subject: [PATCH 1/3] GHA: Add Lint workflow that uses pants --- .github/workflows/lint.yaml | 88 +++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 .github/workflows/lint.yaml diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 0000000000..0252f8d0b6 --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,88 @@ +--- +# This Lint workflow uses pants +name: Lint + +on: + push: + branches: + # only on merges to master branch + - master + # and version branches, which only include minor versions (eg: v3.4) + - v[0-9]+.[0-9]+ + tags: + # also version tags, which include bugfix releases (eg: v3.4.0) + - v[0-9]+.[0-9]+.[0-9]+ + pull_request: + type: [opened, reopened, edited] + branches: + # Only for PRs targeting those branches + - master + - v[0-9]+.[0-9]+ + schedule: + # run every night at midnight + - cron: '0 0 * * *' + +jobs: + # Lint checks which don't depend on any service containes, etc. to be running. + lint-checks: + name: 'Lint Checks (pants runs: shellcheck)' + runs-on: ubuntu-latest + + env: + COLUMNS: '120' + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + # a test uses a submodule, and pants needs access to it to calculate deps. + submodules: 'true' + + #- name: Cache APT Dependencies + # id: cache-apt-deps + # uses: actions/cache@v2 + # with: + # path: | + # ~/apt_cache + # key: ${{ runner.os }}-apt-v7-${{ hashFiles('scripts/github/apt-packages.txt') }} + # restore-keys: | + # ${{ runner.os }}-apt-v7- + - name: Install APT Depedencies + env: + CACHE_HIT: 'false' # cache doesn't work + #CACHE_HIT: ${{steps.cache-apt-deps.outputs.cache-hit}} + run: | + # install dev dependencies for Python YAML and LDAP packages + # https://github.com/StackStorm/st2-auth-ldap + ./scripts/github/install-apt-packages-use-cache.sh + + - name: Initialize Pants and its GHA caches + uses: pantsbuild/actions/init-pants@c0ce05ee4ba288bb2a729a2b77294e9cb6ab66f7 + # This action adds an env var to make pants use both pants.ci.toml & pants.toml. + # This action also creates 3 GHA caches (1 is optional). + # - `pants-setup` has the bootsrapped pants install + # - `pants-named-caches` has pip/wheel and PEX caches + # - `pants-lmdb-store` has the fine-grained process cache. + # If we ever use a remote cache, then we can drop this. + # Otherwise, we may need an additional workflow or job to delete old caches + # if they are not expiring fast enough, and we hit the GHA 10GB per repo max. + with: + base-branch: master + # To ignore a bad cache, bump the cache* integer. + gha-cache-key: cache0 + # This hash should include all of our lockfiles so that the pip/pex caches + # get invalidated on any transitive dependency update. + named-caches-hash: ${{ hashFiles('requirements.txt') }} + # enable the optional lmdb_store cache since we're not using remote caching. + cache-lmdb-store: 'true' + + - name: Lint + run: | + ./pants lint :: + + - name: Upload pants log + uses: actions/upload-artifact@v2 + with: + name: pants-log-py${{ matrix.python-version }} + path: .pants.d/pants.log + if: always() # We want the log even on failures. From 109df1f70b584114993b981b88894218fdbc4f9d Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Wed, 5 Oct 2022 12:04:16 -0500 Subject: [PATCH 2/3] update changelog entry --- CHANGELOG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 526c385bae..77e0c8302d 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -53,7 +53,7 @@ Added * Begin introducing `pants `_ to improve DX (Developer Experience) working on StackStorm, improve our security posture, and improve CI reliability thanks in part - to pants' use of PEX lockfiles. This is not a user-facing addition. #5713 #5724 #5726 #5725 #5732 #5733 #5737 #5738 + to pants' use of PEX lockfiles. This is not a user-facing addition. #5713 #5724 #5726 #5725 #5732 #5733 #5737 #5738 #5758 Contributed by @cognifloyd Changed From 202657c5cc5ebbffaf820e5ba901653371d9bd74 Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Sat, 8 Oct 2022 00:28:49 -0500 Subject: [PATCH 3/3] disable scheduled pants lint until it provides value --- .github/workflows/lint.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 0252f8d0b6..df81433e3b 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -18,9 +18,9 @@ on: # Only for PRs targeting those branches - master - v[0-9]+.[0-9]+ - schedule: - # run every night at midnight - - cron: '0 0 * * *' + #schedule: + # # run every night at midnight + # - cron: '0 0 * * *' jobs: # Lint checks which don't depend on any service containes, etc. to be running.