Skip to content

Commit

Permalink
chore: Allow unsecure node in wheel actions
Browse files Browse the repository at this point in the history
  • Loading branch information
tobni committed Jul 14, 2024
1 parent ac1f683 commit 2413be9
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 47 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ jobs:
container:
image: ghcr.io/pantsbuild/wheel_build_aarch64:v3-8384c5cf
env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
PANTS_REMOTE_CACHE_READ: 'false'
PANTS_REMOTE_CACHE_WRITE: 'false'
if: github.repository_owner == 'pantsbuild'
Expand All @@ -20,7 +21,7 @@ jobs:
- ARM64
steps:
- name: Check out code
uses: actions/checkout@v4
uses: actions/checkout@v3
with:
fetch-depth: 10
ref: ${{ needs.release_info.outputs.build-ref }}
Expand Down Expand Up @@ -57,7 +58,7 @@ jobs:
- continue-on-error: true
if: always()
name: Upload pants.log
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v3
with:
name: logs-wheels-and-pex-Linux-ARM64
overwrite: 'true'
Expand All @@ -84,6 +85,7 @@ jobs:
container:
image: quay.io/pypa/manylinux2014_x86_64:latest
env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
PANTS_REMOTE_CACHE_READ: 'false'
PANTS_REMOTE_CACHE_WRITE: 'false'
if: github.repository_owner == 'pantsbuild'
Expand All @@ -94,7 +96,7 @@ jobs:
- ubuntu-20.04
steps:
- name: Check out code
uses: actions/checkout@v4
uses: actions/checkout@v3
with:
fetch-depth: 10
ref: ${{ needs.release_info.outputs.build-ref }}
Expand Down Expand Up @@ -135,7 +137,7 @@ jobs:
- continue-on-error: true
if: always()
name: Upload pants.log
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v3
with:
name: logs-wheels-and-pex-Linux-x86_64
overwrite: 'true'
Expand Down Expand Up @@ -167,6 +169,7 @@ jobs:
timeout-minutes: 90
build_wheels_macos10_15_x86_64:
env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
PANTS_REMOTE_CACHE_READ: 'false'
PANTS_REMOTE_CACHE_WRITE: 'false'
if: github.repository_owner == 'pantsbuild'
Expand Down Expand Up @@ -252,6 +255,7 @@ jobs:
timeout-minutes: 90
build_wheels_macos11_arm64:
env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
PANTS_REMOTE_CACHE_READ: 'false'
PANTS_REMOTE_CACHE_WRITE: 'false'
if: github.repository_owner == 'pantsbuild'
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ jobs:
container:
image: ghcr.io/pantsbuild/wheel_build_aarch64:v3-8384c5cf
env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
MODE: debug
PANTS_REMOTE_CACHE_READ: 'false'
PANTS_REMOTE_CACHE_WRITE: 'false'
Expand All @@ -315,7 +316,7 @@ jobs:
- ARM64
steps:
- name: Check out code
uses: actions/checkout@v4
uses: actions/checkout@v3
with:
fetch-depth: 10
- name: Configure Git
Expand Down Expand Up @@ -350,7 +351,7 @@ jobs:
- continue-on-error: true
if: always()
name: Upload pants.log
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v3
with:
name: logs-wheels-and-pex-Linux-ARM64
overwrite: 'true'
Expand All @@ -360,6 +361,7 @@ jobs:
container:
image: quay.io/pypa/manylinux2014_x86_64:latest
env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
MODE: debug
PANTS_REMOTE_CACHE_READ: 'false'
PANTS_REMOTE_CACHE_WRITE: 'false'
Expand All @@ -372,7 +374,7 @@ jobs:
- ubuntu-20.04
steps:
- name: Check out code
uses: actions/checkout@v4
uses: actions/checkout@v3
with:
fetch-depth: 10
- name: Configure Git
Expand Down Expand Up @@ -411,14 +413,15 @@ jobs:
- continue-on-error: true
if: always()
name: Upload pants.log
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v3
with:
name: logs-wheels-and-pex-Linux-x86_64
overwrite: 'true'
path: .pants.d/workdir/*.log
timeout-minutes: 90
build_wheels_macos10_15_x86_64:
env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
MODE: debug
PANTS_REMOTE_CACHE_READ: 'false'
PANTS_REMOTE_CACHE_WRITE: 'false'
Expand Down Expand Up @@ -487,6 +490,7 @@ jobs:
timeout-minutes: 90
build_wheels_macos11_arm64:
env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
MODE: debug
PANTS_REMOTE_CACHE_READ: 'false'
PANTS_REMOTE_CACHE_WRITE: 'false'
Expand Down
86 changes: 47 additions & 39 deletions src/python/pants_release/generate_github_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,31 @@

from pants.util.strutil import softwrap

ACTION = {
"action-send-mail": "dawidd6/[email protected]",
"cache": "actions/cache@v4",
"checkout": "actions/checkout@v4",
"download-artifact": "actions/download-artifact@v4",
"expose-pythons": "pantsbuild/actions/expose-pythons@627a8ce25d972afa03da1641be9261bbbe0e3ffe",
"github-action-required-labels": "mheap/[email protected]",
"rust-cache": "benjyw/rust-cache@461b9f8eee66b575bce78977bf649b8b7a8d53f1",
"setup-go": "actions/setup-go@v5",
"setup-java": "actions/setup-java@v4",
"setup-node": "actions/setup-node@v4",
"setup-protoc": "arduino/setup-protoc@9b1ee5b22b0a3f1feb8c2ff99b32c89b3c3191e9",
"setup-python": "actions/setup-python@v5",
"slack-github-action": "slackapi/[email protected]",
"upload-artifact": "actions/upload-artifact@v4",
}

def action(name: str, node16_compat: bool = False) -> str:
if node16_compat:
return {
"checkout": "actions/checkout@v3",
"upload-artifact": "actions/upload-artifact@v3",
}[name]
else:
return {
"action-send-mail": "dawidd6/[email protected]",
"cache": "actions/cache@v4",
"checkout": "actions/checkout@v4",
"download-artifact": "actions/download-artifact@v4",
"expose-pythons": "pantsbuild/actions/expose-pythons@627a8ce25d972afa03da1641be9261bbbe0e3ffe",
"github-action-required-labels": "mheap/[email protected]",
"rust-cache": "benjyw/rust-cache@461b9f8eee66b575bce78977bf649b8b7a8d53f1",
"setup-go": "actions/setup-go@v5",
"setup-java": "actions/setup-java@v4",
"setup-node": "actions/setup-node@v4",
"setup-protoc": "arduino/setup-protoc@9b1ee5b22b0a3f1feb8c2ff99b32c89b3c3191e9",
"setup-python": "actions/setup-python@v5",
"slack-github-action": "slackapi/[email protected]",
"upload-artifact": "actions/upload-artifact@v4",
}[name]


HEADER = dedent(
"""\
Expand Down Expand Up @@ -170,7 +179,7 @@ def ensure_category_label() -> Sequence[Step]:
{
"if": "github.event_name == 'pull_request'",
"name": "Ensure category label",
"uses": ACTION["github-action-required-labels"],
"uses": action("github-action-required-labels"),
"env": {"GITHUB_TOKEN": gha_expr("secrets.GITHUB_TOKEN")},
"with": {
"mode": "exactly",
Expand All @@ -197,7 +206,7 @@ def ensure_release_notes() -> Sequence[Step]:
# out via a label.
"if": "github.event_name == 'pull_request' && !needs.classify_changes.outputs.notes",
"name": "Ensure appropriate label",
"uses": ACTION["github-action-required-labels"],
"uses": action("github-action-required-labels"),
"env": {"GITHUB_TOKEN": gha_expr("secrets.GITHUB_TOKEN")},
"with": {
"mode": "minimum",
Expand Down Expand Up @@ -237,7 +246,7 @@ def checkout(
# We need to fetch a few commits back, to be able to access HEAD^2 in the PR case.
{
"name": "Check out code",
"uses": ACTION["checkout"],
"uses": action("checkout", node16_compat=containerized),
"with": {
**fetch_depth_opt,
**({"ref": ref} if ref else {}),
Expand Down Expand Up @@ -339,23 +348,23 @@ def install_rustup() -> Step:
def install_python(version: str) -> Step:
return {
"name": f"Set up Python {version}",
"uses": ACTION["setup-python"],
"uses": action("setup-python"),
"with": {"python-version": version},
}


def install_node(version: str) -> Step:
return {
"name": f"Set up Node {version}",
"uses": ACTION["setup-node"],
"uses": action("setup-node"),
"with": {"node-version": version},
}


def install_jdk() -> Step:
return {
"name": "Install AdoptJDK",
"uses": ACTION["setup-java"],
"uses": action("setup-java"),
"with": {
"distribution": "adopt",
"java-version": "11",
Expand All @@ -366,7 +375,7 @@ def install_jdk() -> Step:
def install_go() -> Step:
return {
"name": "Install Go",
"uses": ACTION["setup-go"],
"uses": action("setup-go"),
"with": {"go-version": "1.19.5"},
}

Expand All @@ -377,7 +386,7 @@ def install_go() -> Step:
def install_protoc() -> Step:
return {
"name": "Install Protoc",
"uses": ACTION["setup-protoc"],
"uses": action("setup-protoc"),
"with": {
"version": "23.x",
"repo-token": "${{ secrets.GITHUB_TOKEN }}",
Expand Down Expand Up @@ -470,7 +479,7 @@ def wrap_cmd(self, cmd: str) -> str:
def native_binaries_upload(self) -> Step:
return {
"name": "Upload native binaries",
"uses": ACTION["upload-artifact"],
"uses": action("upload-artifact"),
"with": {
"name": f"native_binaries.{gha_expr('matrix.python-version')}.{self.platform_name()}",
"path": "\n".join(NATIVE_FILES),
Expand All @@ -481,7 +490,7 @@ def native_binaries_download(self) -> Sequence[Step]:
return [
{
"name": "Download native binaries",
"uses": ACTION["download-artifact"],
"uses": action("download-artifact"),
"with": {
"name": f"native_binaries.{gha_expr('matrix.python-version')}.{self.platform_name()}",
"path": NATIVE_FILES_COMMON_PREFIX,
Expand All @@ -502,15 +511,15 @@ def rust_caches(self) -> Sequence[Step]:
},
{
"name": "Cache Rust toolchain",
"uses": ACTION["cache"],
"uses": action("cache"),
"with": {
"path": f"~/.rustup/toolchains/{rust_channel()}-*\n~/.rustup/update-hashes\n~/.rustup/settings.toml\n",
"key": f"{self.platform_name()}-rustup-{hash_files('src/rust/engine/rust-toolchain')}-v2",
},
},
{
"name": "Cache Cargo",
"uses": ACTION["rust-cache"],
"uses": action("rust-cache"),
"with": {
# If set, replaces the job id in the cache key, so that the cache is stable across jobs.
# If we don't set this, each job may restore from a previous job's cache entry (via a
Expand Down Expand Up @@ -540,7 +549,7 @@ def bootstrap_caches(self) -> Sequence[Step]:
},
{
"name": "Cache native engine",
"uses": ACTION["cache"],
"uses": action("cache"),
"with": {
"path": "\n".join(NATIVE_FILES),
"key": f"{self.platform_name()}-engine-{gha_expr('steps.get-engine-hash.outputs.hash')}-v1",
Expand All @@ -564,7 +573,7 @@ def expose_all_pythons(self) -> Sequence[Step]:
ret.append(
{
"name": "Expose Pythons",
"uses": ACTION["expose-pythons"],
"uses": action("expose-pythons"),
}
)
return ret
Expand Down Expand Up @@ -598,10 +607,10 @@ def bootstrap_pants(self) -> Sequence[Step]:
self.native_binaries_upload(),
]

def upload_log_artifacts(self, name: str) -> Step:
def upload_log_artifacts(self, name: str, node16_compat: bool = False) -> Step:
return {
"name": "Upload pants.log",
"uses": ACTION["upload-artifact"],
"uses": action("upload-artifact", node16_compat=node16_compat),
"if": "always()",
"continue-on-error": True,
"with": {
Expand Down Expand Up @@ -860,9 +869,7 @@ def build_wheels_job(
elif platform == Platform.LINUX_ARM64:
# Unfortunately Equinix do not support the CentOS 7 image on the hardware we've been
# generously given by the Works on ARM program. So we have to build in this image.
container = {
"image": "ghcr.io/pantsbuild/wheel_build_aarch64:v3-8384c5cf",
}
container = {"image": "ghcr.io/pantsbuild/wheel_build_aarch64:v3-8384c5cf"}
else:
container = None

Expand Down Expand Up @@ -904,6 +911,7 @@ def build_wheels_job(
**({"needs": needs} if needs else {}),
"timeout-minutes": 90,
"env": {
"ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION": True,
**DISABLE_REMOTE_CACHE_ENV,
# If we're not deploying these wheels, build in debug mode, which allows for
# incremental compilation across wheels. If this becomes too slow in CI, most likely
Expand All @@ -925,7 +933,7 @@ def build_wheels_job(
"run": "./pants package src/python/pants:pants-pex",
"env": helper.platform_env(),
},
helper.upload_log_artifacts(name="wheels-and-pex"),
helper.upload_log_artifacts(name="wheels-and-pex", node16_compat=bool(container)),
*(
[
{
Expand Down Expand Up @@ -1236,7 +1244,7 @@ def release_jobs_and_inputs() -> tuple[Jobs, dict[str, Any]]:
"steps": [
{
"name": "Checkout Pants at Release Tag",
"uses": ACTION["checkout"],
"uses": action("checkout"),
"with": {
# N.B.: We need the last few edits to VERSION. Instead of guessing, just
# clone the repo, we're not so big as to need to optimize this.
Expand All @@ -1259,7 +1267,7 @@ def release_jobs_and_inputs() -> tuple[Jobs, dict[str, Any]]:
},
{
"name": "Announce to Slack",
"uses": ACTION["slack-github-action"],
"uses": action("slack-github-action"),
"with": {
"channel-id": "C18RRR4JK",
"payload-file-path": "${{ runner.temp }}/slack_announcement.json",
Expand All @@ -1268,7 +1276,7 @@ def release_jobs_and_inputs() -> tuple[Jobs, dict[str, Any]]:
},
{
"name": "Announce to pants-devel",
"uses": ACTION["action-send-mail"],
"uses": action("action-send-mail"),
"with": {
# Note: Email is sent from the dedicated account [email protected].
# The EMAIL_CONNECTION_URL should be of the form:
Expand Down

0 comments on commit 2413be9

Please sign in to comment.