Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stage artifacts during CI run #17

Merged
merged 10 commits into from
Dec 6, 2023
55 changes: 55 additions & 0 deletions .github/artifacts/stage_ci_files.py
dixonjoel marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
"""Stage client files."""

from argparse import ArgumentParser
from pathlib import Path
from shutil import copy2
from tempfile import TemporaryDirectory

class _ArtifactLocations:
repo_root: Path

def __init__(self, repo_root: Path):
self.repo_root = repo_root

@property
def proto_files(self) -> Path:
return self.repo_root


def stage_ci_files(output_path: Path):
"""Stage the client files into the given output path."""
repo_root = Path(__file__).parent.parent.parent
artifact_locations = _ArtifactLocations(repo_root)

proto_path = output_path / "proto"
proto_path.mkdir(parents=True)

for file in artifact_locations.proto_files.glob("*.proto"):
copy2(file, proto_path)


if __name__ == "__main__":
parser = ArgumentParser(description="Stage ni-api files.")
parser.add_argument(
"--output",
"-o",
help="The path to the top-level directory to stage the client files. Must be empty or non-existent.",
)

args = parser.parse_args()

if args.output:
stage_ci_files(Path(args.output))
else:
print(
"""
***No --output directory specified.***
Performing Dry Run.
"""
)
with TemporaryDirectory() as tempdir:
tempdirpath = Path(tempdir)
stage_ci_files(tempdirpath)
created_files = (f for f in tempdirpath.glob("**/*") if not f.is_dir())
for out_file in created_files:
print(out_file.relative_to(tempdirpath))
dixonjoel marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ on:
jobs:
check_protos:
name: Check .proto files
uses: ./.github/workflows/check_protos.yml
uses: ./.github/workflows/check_protos.yml
dixonjoel marked this conversation as resolved.
Show resolved Hide resolved
create_ci_artifacts:
uses: ./.github/workflows/create_ci_artifacts.yml

35 changes: 35 additions & 0 deletions .github/workflows/create_ci_artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Create CI Artifacts

on:
workflow_call:
workflow_dispatch:

jobs:
build:
name: 'Proto Artifacts'
runs-on: 'windows-latest'

steps:
- name: Checkout Repo
uses: actions/checkout@v2

- name: Setup python3
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install build dependencies
run: python -m pip install -r python_build_requirements.txt

- name: Stage Client Files
dixonjoel marked this conversation as resolved.
Show resolved Hide resolved
run: |
python ./.github/artifacts/stage_ci_files.py -o ${{ runner.temp }}/staging/

- name: Upload Windows Client Files Artifact
dixonjoel marked this conversation as resolved.
Show resolved Hide resolved
uses: actions/upload-artifact@v2
if: ${{ (github.ref == 'refs/heads/main') }}
with:
name: ni-apis
path: |
${{ runner.temp }}/staging
retention-days: 5
9 changes: 9 additions & 0 deletions python_build_requirements.txt
dixonjoel marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
contextlib2==21.6.0
Mako==1.2.2
MarkupSafe==2.0.1
schema==0.7.4
black>=21.10b0
mypy>=0.910
ni-python-styleguide~=0.1
pycodestyle==2.7.0
importlib-metadata==4.12.0
Loading