-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
01186ed
commit ab0dcbd
Showing
8 changed files
with
280 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
# This is a basic workflow to help you get started with Actions | ||
|
||
name: FRC CI Checks | ||
|
||
# Controls when the action will run. | ||
on: | ||
workflow_call: | ||
|
||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
linting: | ||
name: Linting | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 # v2 minimum required | ||
- name: Run check style | ||
uses: dbelyaev/action-checkstyle@master | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
reporter: 'github-check' | ||
fail_on_error: true | ||
filter_mode: nofilter | ||
level: error | ||
checkstyle_config: checks.xml | ||
spell_check: | ||
name: Spell Check | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 # v2 minimum required | ||
- name: Run Spell Check | ||
uses: codespell-project/actions-codespell@master | ||
with: | ||
check_filenames: true | ||
merge_conflict_job: | ||
runs-on: ubuntu-latest | ||
name: Find merge conflicts | ||
steps: | ||
# Checkout the source code so there are some files to look at. | ||
- uses: actions/checkout@v4 | ||
# Run the actual merge conflict finder | ||
- name: Merge Conflict finder | ||
uses: olivernybroe/[email protected] | ||
build-javadoc: | ||
name: Build Javadocs | ||
# The type of runner that the job will run on | ||
runs-on: ubuntu-latest | ||
# This grabs the WPILib docker container | ||
container: wpilib/roborio-cross-ubuntu:2025-24.04 | ||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
- uses: actions/checkout@v4 | ||
# Grant execute permission for gradlew | ||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
# Runs a single command using the runners shell | ||
- name: Create Javadocs | ||
run: ./gradlew javadoc | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: javadocs | ||
path: './build/docs/javadoc' | ||
deploy-javadoc: | ||
if: success() && github.ref_name == github.event.repository.default_branch | ||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
permissions: | ||
contents: read | ||
pages: write | ||
id-token: write | ||
concurrency: | ||
group: "pages" | ||
cancel-in-progress: true | ||
name: Deploy Javadocs | ||
# The type of runner that the job will run on | ||
runs-on: ubuntu-latest | ||
needs: build-javadoc | ||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: javadocs | ||
path: './build/docs/javadoc' | ||
- name: Setup Pages | ||
uses: actions/configure-pages@v5 | ||
- name: Deploy to Github Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v4 | ||
build: | ||
name: Build | ||
# The type of runner that the job will run on | ||
runs-on: ubuntu-latest | ||
# This grabs the WPILib docker container | ||
container: wpilib/roborio-cross-ubuntu:2025-24.04 | ||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
- uses: actions/checkout@v4 | ||
# Grant execute permission for gradlew | ||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
# Runs a single command using the runners shell | ||
- name: Compile and run tests on robot code | ||
run: ./gradlew build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# This is a basic workflow to help you get started with Actions | ||
|
||
name: CI | ||
|
||
# Controls when the action will run. | ||
on: | ||
# Triggers the workflow on push | ||
push: | ||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
permissions: | ||
packages: write | ||
contents: read | ||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
build-container: | ||
name: Build | ||
# The type of runner that the job will run on | ||
runs-on: ubuntu-latest | ||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
- uses: actions/checkout@v4 | ||
- uses: docker/login-action@v2 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: "./vendor-update" | ||
file: "./vendor-update/Dockerfile" | ||
push: true | ||
tags: ${{ env.REGISTRY }}/frc5572/worflows/vendor-update:${{ github.ref_name }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
name: Check for Vendor Dependencies | ||
|
||
# Controls when the action will run. | ||
on: | ||
workflow_call: | ||
inputs: | ||
base_branch: | ||
required: true | ||
type: string | ||
default: main | ||
version: | ||
required: true | ||
type: string | ||
default: main | ||
|
||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
vendor-update-check: | ||
name: Linting | ||
runs-on: ubuntu-latest | ||
container: ghcr.io/Frc5572/Worflows/vendor-update:${{ inputs.version }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Run Update check | ||
run: python /app/vendor-update.py | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
BASE_BRANCH: ${{ inputs.base_branch }} | ||
REPO_PATH: ${{ github.repository }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.venv | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM python:3.13-alpine | ||
|
||
WORKDIR /app | ||
COPY pr-template.j2 requirements.txt vendor-update.py /app/ | ||
RUN python -m pip install -U pip setuptools && pip install -r requirements.txt | ||
ENTRYPOINT [ "python" ] | ||
CMD [ "vendor-update.py" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# SUMMARY | ||
The following vendor dependencies have been updated. | ||
|
||
| Vendor | Change | | ||
|---|---| | ||
{% for item in deps -%} | ||
| {{ item.name }} | {{ item.old_version }} -> {{ item.new_version }} | | ||
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
requests | ||
packaging | ||
PyGithub | ||
GitPython | ||
Jinja2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import json | ||
import re | ||
import sys | ||
from pathlib import Path | ||
import os | ||
|
||
import requests | ||
from git import Repo, exc | ||
from github import Auth, Github, PullRequest | ||
from packaging.version import parse | ||
from jinja2 import Template | ||
|
||
|
||
REGEX = r"(?P<name>[^\s-]+)(?P<versioned>-\d+\.\d+\.\d+)?" | ||
UPDATED_DEPS = [] | ||
BRANCH_NAME = "vendordeps-update" | ||
SCRIPT_PATH = Path(os.path.dirname(os.path.abspath(sys.argv[0]))) | ||
GITHUB_TOKEN = os.getenv("GITHUB_TOKEN", None) | ||
BASE_BRANCH = os.getenv("BASE_BRANCH", "main") | ||
REPO_PATH = os.getenv("REPO_PATH", None) | ||
|
||
if __name__ == "__main__": | ||
auth = Auth.Token(GITHUB_TOKEN) | ||
g = Github(auth=auth) | ||
repo = Repo(Path.cwd()) | ||
try: | ||
repo.delete_head(BRANCH_NAME) | ||
except exc.GitCommandError: | ||
pass | ||
new_branch = repo.create_head(BRANCH_NAME) | ||
new_branch.checkout(force=True) | ||
|
||
_dir = Path.cwd().joinpath("vendordeps") | ||
for file in _dir.glob("*.json"): | ||
print(file.stem) | ||
with file.open(mode="r", encoding="utf-8") as f: | ||
vendor: dict = json.load(f) | ||
file_regex = re.match(REGEX, file.stem) | ||
json_url = vendor.get("jsonUrl", None) | ||
version = vendor.get("version") | ||
if json_url is None or json_url == "": | ||
continue | ||
new_vendor: dict = requests.get(json_url).json() | ||
new_version = new_vendor.get("version") | ||
if parse(new_version) <= parse(version): | ||
continue | ||
UPDATED_DEPS.append( | ||
{ | ||
"name": file_regex.groupdict().get("name", None), | ||
"old_version": version, | ||
"new_version": new_version, | ||
} | ||
) | ||
file_version = "" | ||
if file_regex.groupdict().get("versioned", None) is not None: | ||
file_version = f"-{new_version}" | ||
new_file = f"{file_regex.groupdict().get("name", None)}{file_version}.json" | ||
with _dir.joinpath(new_file).open(mode="w", encoding="utf-8") as f: | ||
new_vendor["fileName"] = new_file | ||
json.dump(new_vendor, f, indent=4) | ||
file.unlink() | ||
untracked = repo.untracked_files | ||
diffs = [x.a_path for x in repo.index.diff(None)] | ||
modified_deps = [x for x in untracked + diffs if x.startswith("vendordeps")] | ||
if len(modified_deps) == 0: | ||
print("No vendor updates") | ||
sys.exit(0) | ||
repo.git.add("vendordeps/*") | ||
repo.index.commit("Updating Vendor Dependencies again") | ||
repo.git.push("--force", "--set-upstream", "origin", repo.head.ref) | ||
|
||
gh_repo = g.get_repo(REPO_PATH) | ||
pulls = gh_repo.get_pulls( | ||
state="open", sort="created", base=BASE_BRANCH, head=f"Frc5572:{BRANCH_NAME}" | ||
) | ||
with open(SCRIPT_PATH.joinpath("pr-template.j2")) as f: | ||
body = Template(f.read()).render(deps=UPDATED_DEPS) | ||
if pulls.totalCount == 0: | ||
gh_repo.create_pull(base=BASE_BRANCH, head=BRANCH_NAME, title="Vendor Dependency Updates", body=body, draft=True) | ||
elif pulls.totalCount == 1: | ||
pull: PullRequest = pulls[0] | ||
pull.edit(body=body) |