import subprocess from gh import gh from update_common import process_update_on_repos dockerfile = os.path.join(gh.root, "docker_build", "docker", gh.tool, "Dockerfile") print("Reading Dockerfile %s…" % dockerfile) repo = None commit = None repo_rx = r"ARG\s+(?:\w+?)_REPO\s*=\s*([^\s]+)" commit_rx = r"ARG\s+(?:\w+?)_COMMIT\s*=\s*([^\s]+)" with open(dockerfile) as f: for line in f: repo_match = re.match(repo_rx, line) if repo_match is not None: repo = repo_match[1] commit_match = re.match(commit_rx, line) if commit_match is not None: commit = commit_match[1] tool = gh.Repo(gh.tool, repo, r"refs/heads/CID\-latest\-tools\-%s(?:\-(\w+))?" % gh.tool) tool.commit = commit print("Found %s@%s (latest: %s)." % (tool.url, tool.commit, tool.latest_commit)) changed = process_update_on_repos([tool], [dockerfile]) gh.export_env("TOOL_COMMIT_HASH", tool.latest_commit) gh.export_env("NO_UPDATE", "false" if changed else "true")
makefile = os.path.join(gh.root, "Makefile") documentation = os.path.join(gh.root, "docs", "source", "Manual_PDK_installation.md") print("Reading Makefile…") skywater = gh.Repo("Skywater PDK", "https://github.com/google/skywater-pdk.git", r"refs/heads/CID\-latest\-pdk(?:\-(\w+)-(?:\w+))?", r"SKYWATER_COMMIT\s*\?=\s*(\w+)") open_pdks = gh.Repo("Open PDKs", "https://github.com/rtimothyedwards/open_pdks", r"refs/heads/CID\-latest\-pdk(?:\-(?:\w+)-(\w+))?", r"OPEN_PDKS_COMMIT\s*\?=\s*(\w+)") with open(makefile) as f: for line in f: skywater.commit = skywater.match_line(line) or skywater.commit open_pdks.commit = open_pdks.match_line(line) or open_pdks.commit print("Found %s:%s. (latest: %s)" % (skywater.url, skywater.commit, skywater.latest_commit)) print("Found %s:%s. (latest: %s)" % (open_pdks.url, open_pdks.commit, open_pdks.latest_commit)) changed = process_update_on_repos([skywater, open_pdks], [makefile, documentation]) gh.export_env("SKYWATER_COMMIT_HASH", skywater.latest_commit) gh.export_env("OPEN_PDKS_COMMIT_HASH", open_pdks.latest_commit) gh.export_env("NO_UPDATE", "false" if changed else "true")
dump_options = {'sort_keys': False} changes = False for tool_name in args.tools: tool = tools[tool_name] repo = gh.Repo(tool_name, tool.repo) repo.commit = tool.commit print("Found %s@%s (latest: %s)." % (repo.url, repo.commit, repo.latest_commit)) if repo.commit != repo.latest_commit: changes = True metadata_str = open(metadata_path).read() metadata = yaml.safe_load(metadata_str) for tool in metadata: if tool['name'] == tool_name: tool['commit'] = repo.latest_commit metadata_str = yaml.dump(metadata, **dump_options) with open(metadata_path, "w") as f: f.write(metadata_str) if len(args.tools) == 1: gh.export_env("TOOL_COMMIT_HASH", repo.latest_commit) else: gh.export_env(f"{tool_name.upper()}_COMMIT_HASH", repo.latest_commit) gh.export_env("NO_UPDATE", "0" if changes else "1")
prefix = lri if lri is not None else "v0" print("Using prefix %s, getting the latest tag…" % prefix) latest_tag = "%s.0" % prefix # Base case: Will create prefix.1 latest_tag_commit = "dad497fccc1b48f4f16e570b0214b6f0e1fc2f9b" # Base case: First commit, always > 2 for tag in gh.openlane.tags: commit, name = tag if name.startswith(prefix): latest_tag = name latest_tag_commit = commit commit_count = int(subprocess.check_output(["git", "rev-list", "--count", "%s..%s" % (latest_tag_commit, "HEAD")])) if commit_count < 2: print("Only %i out of 2 new commits required for a new tag." % commit_count) gh.export_env("NEW_TAG", "NO_NEW_TAG") exit(0) new_tag = None if not latest_tag.startswith("v"): new_tag = "%s.1" % prefix print("Last tag (%s) lacked a v, replacing with %s…" % (latest_tag, new_tag)) else: current = int(latest_tag.split(".")[1]) new = current + 1 new_tag = "%s.%i" % (prefix, new) print("Naming new tag %s." % new_tag) gh.export_env("NEW_TAG", new_tag)
# you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from gh import gh import os import json github_event_name = os.environ["EVENT_NAME"] if github_event_name in ["schedule", "workflow_dispatch"]: gh.export_env("USE_ETS", "1") elif github_event_name == "pull_request": gh_event_str = open(os.environ["GITHUB_EVENT_PATH"]).read() gh_event = json.loads(gh_event_str) pr_body = gh_event["pull_request"]["body"] if "[ci ets]" in pr_body: gh.export_env("USE_ETS", "1") else: gh.export_env("USE_ETS", "0") else: gh.export_env("USE_ETS", "0")