Skip to content

Commit

Permalink
Add PR CI workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
illicitonion committed Dec 20, 2024
1 parent 4441d23 commit d126af8
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 4 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Release
'on':
workflow_dispatch: null
pull_request: null
jobs:
pr-generate:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/[email protected]
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- run: ./download-buildifier.sh
- run: git config --global user.email "[email protected]" && git config --global user.name "Raccoons Build"
- name: Checkout BCR
uses: actions/[email protected]
with:
repository: illicitonion/bazel-central-registry
token: ${{ secrets.BCR_GITHUB_TOKEN }}
path: bazel-central-registry
ref: refs/heads/main
- run: (cd bazel-central-registry && git remote add upstream https://github.com/bazelbuild/bazel-central-registry.git && git fetch upstream && git reset --hard upstream/main)
- run: python3 generate.py --bcr_dir=$(pwd)/bazel-central-registry --overlay_tar_path=/tmp/3.3.1.bcr.wip.tar.gz --tag=3.3.1.bcr.wip --release_tar_url_template=file:///tmp/3.3.1.bcr.wip.tar.gz --buildifier=/tmp/buildifier.exe
- run: tar czf bcr.tar.gz bazel-central-registry
- name: Upload overlay
uses: actions/upload-artifact@v3
with:
name: 3.3.1.bcr.wip.tar.gz
path: /tmp/3.3.1.bcr.wip.tar.gz
if-no-files-found: error
- name: Upload bcr
uses: actions/upload-artifact@v3
with:
name: bcr.tar.gz
path: bcr.tar.gz
if-no-files-found: error
pr-test:
strategy:
matrix:
os:
- macos-13
- macos-14
- ubuntu-latest
needs:
- pr-generate
runs-on: ${{ matrix.os }}
steps:
- name: Download overlay
uses: actions/download-artifact@v3
with:
name: 3.3.1.bcr.wip.tar.gz
path: /tmp/
- name: Download bcr
uses: actions/download-artifact@v3
with:
name: bcr.tar.gz
path: /tmp/
- run: (cd /tmp && tar xzf /tmp/bcr.tar.gz)
- run: mkdir workspace && cd workspace && echo 8.0.0 > .bazelversion && echo 'bazel_dep(name = "openssl", version = "3.3.1.bcr.wip")' > MODULE.bazel && bazel test --registry="file:///tmp/bazel-central-registry" @openssl//...
19 changes: 19 additions & 0 deletions download-buildifier.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

set -euo pipefail

case "$(uname)" in
"Darwin")
suffix="darwin-amd64"
;;
"Linux")
suffix="linux-amd64"
;;
*)
echo >&2 "Unknown uname $(uname)"
exit 1
;;
esac

curl --fail -L -o /tmp/buildifier.exe "https://github.com/bazelbuild/buildtools/releases/download/v7.3.1/buildifier-${suffix}"
chmod 0755 /tmp/buildifier.exe
12 changes: 8 additions & 4 deletions generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
]


def main(bcr_dir: str, overlay_tar_path: str, tag: str, release_tar_url_template: str):
def main(bcr_dir: str, overlay_tar_path: str, tag: str, buildifier_path: str, release_tar_url_template: str):
openssl_module_dir = os.path.join(bcr_dir, "modules", "openssl")
out_dir = os.path.join(openssl_module_dir, tag)
os.makedirs(out_dir)
Expand Down Expand Up @@ -153,6 +153,7 @@ def main(bcr_dir: str, overlay_tar_path: str, tag: str, release_tar_url_template
path: generated_path_to_platform_to_contents[path][platform]
for path in platform_specific_generated_paths
},
buildifier_path,
)

copy_from_here_to(
Expand Down Expand Up @@ -209,7 +210,8 @@ def main(bcr_dir: str, overlay_tar_path: str, tag: str, release_tar_url_template
write_source_json(out_dir, openssl_info)

previous_tag_dir = guess_previous_tag_dir(openssl_module_dir, tag)
dedupe_content_with_symlinks(previous_tag_dir, out_dir)
if previous_tag_dir:
dedupe_content_with_symlinks(previous_tag_dir, out_dir)

add_to_metadata(openssl_module_dir, tag)

Expand Down Expand Up @@ -307,6 +309,7 @@ def write_platform_specific_constants(
platform: str,
perl_output: str,
platform_specific_generated_files: Dict[str, str],
buildifier_path: str,
):
out = f"""# Generated code. DO NOT EDIT.
Expand All @@ -319,7 +322,7 @@ def write_platform_specific_constants(
path = os.path.join(overlay_dir, f"constants-{platform}.bzl")
with open(path, "w") as f:
f.write(out)
subprocess.check_call(["buildifier", path])
subprocess.check_call([buildifier_path, path])


def copy_from_here_to(local_path: str, dst: str, executable: bool = False):
Expand Down Expand Up @@ -382,5 +385,6 @@ def dedupe_content_with_symlinks(previous_tag_dir, out_dir):
"--release_tar_url_template",
default="https://github.com/raccoons-build/bazel-openssl-cc/releases/download/{tag}/bazel-openssl-cc-{tag}.tar.gz",
)
parser.add_argument("--buildifier", default="buildifier")
args = parser.parse_args()
main(args.bcr_dir, args.overlay_tar_path, args.tag, args.release_tar_url_template)
main(args.bcr_dir, args.overlay_tar_path, args.tag, args.buildifier, args.release_tar_url_template)

0 comments on commit d126af8

Please sign in to comment.