-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into pr/ion098/8
- Loading branch information
Showing
39 changed files
with
1,051 additions
and
807 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,38 @@ | ||
# automatically format code using clang-format when a pull request is merged or manually triggered | ||
name: format-code | ||
|
||
on: | ||
pull_request: | ||
types: [closed] # on merge pull request | ||
workflow_dispatch: # allows manual triggering | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
format: | ||
if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch' | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Format code # Outputs the correctly formatted code | ||
uses: DoozyX/[email protected] | ||
with: | ||
source: './src/hardware ./include/hardware' | ||
extensions: 'hpp,cpp' | ||
clangFormatVersion: 18 | ||
inplace: true # Same as `clang-format -i` | ||
|
||
# Commits the correctly formatted files to the repository | ||
- name: Commit changes | ||
uses: EndBug/add-and-commit@v9 | ||
with: | ||
author_name: GitHub Action | ||
author_email: [email protected] | ||
message: Automated code formatting | ||
push: true | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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,26 @@ | ||
name: Populate Depot json | ||
|
||
on: | ||
# runs when this repository's releases are modified | ||
release: | ||
# allows for manual dispatching of the workflow | ||
workflow_dispatch: | ||
|
||
jobs: | ||
populate: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
# permits reading of releases and writing to the depot branch | ||
contents: write | ||
steps: | ||
# where to find gh action and what version to use | ||
- uses: LemLib/[email protected] | ||
with: | ||
# gives the github action the permissions specified above | ||
token: ${{ github.token }} | ||
# target repo for depots | ||
repo: LemLib/hardware | ||
# where to read releases from (can be omitted if repo is also the repo from which to read releases from, but it doesn't sem to be working at the moment) | ||
source-repo: LemLib/hardware | ||
# makes the json output human readable | ||
readable-json: true |
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,90 @@ | ||
name: Add Template to Pull Request | ||
on: | ||
workflow_run: | ||
workflows: ['PROS Build Template'] | ||
types: [completed] | ||
jobs: | ||
pr_comment: | ||
# if Build Template was successful and ran on a branch that is currently the head in a pull request | ||
if: github.event.workflow_run.conclusion == 'success' | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
pull-requests: write | ||
|
||
steps: | ||
- uses: actions/github-script@v6 | ||
with: | ||
# This snippet is public-domain, taken from | ||
# https://github.com/oprypin/nightly.link/blob/master/.github/workflows/pr-comment.yml | ||
script: | | ||
async function upsertComment(owner, repo, issue_number, purpose,old_body, body) { | ||
const {data: comments} = await github.rest.issues.listComments( | ||
{owner, repo, issue_number}); | ||
const marker = `\r\n<!-- DO NOT REMOVE!! -->\r\n<!-- bot: ${purpose} -->\r\n`; | ||
const old_marker = new RegExp(marker.replace("\r\n", "\r?\n")).exec(old_body)?.[0] ?? marker; | ||
body = old_body.split(old_marker)[0] + marker + body; | ||
await github.request('PATCH /repos/{owner}/{repo}/pulls/{pull_number}', { | ||
owner: owner, | ||
repo: repo, | ||
pull_number: issue_number, | ||
body: body, | ||
headers: { | ||
'X-GitHub-Api-Version': '2022-11-28' | ||
} | ||
}) | ||
} | ||
const {owner, repo} = context.repo; | ||
const run_id = ${{github.event.workflow_run.id}}; | ||
const pull_head_sha = '${{github.event.workflow_run.head_sha}}'; | ||
/** @type {{old_body: string}} */ | ||
const {issue_number, old_body} = await (async () => { | ||
const pulls = await github.rest.pulls.list({owner, repo}); | ||
for await (const {data} of github.paginate.iterator(pulls)) { | ||
for (const pull of data) { | ||
if (pull.head.sha === pull_head_sha) { | ||
return {issue_number: pull.number, old_body: pull.body}; | ||
} | ||
} | ||
} | ||
return {}; | ||
})(); | ||
if (issue_number) { | ||
core.info(`Using pull request ${issue_number}`); | ||
} else { | ||
return core.error(`No matching pull request found`); | ||
} | ||
let old_sha = /\<\!-- commit-sha: (?<sha>[a-z0-9]+) --\>/i.exec(old_body)?.groups?.sha | ||
if (old_sha != undefined && pull_head_sha == old_sha) return core.error("Comment is already up-to-date!") | ||
const artifacts = await github.paginate( | ||
github.rest.actions.listWorkflowRunArtifacts, {owner, repo, run_id}); | ||
if (!artifacts.length) { | ||
return core.error(`No artifacts found, perhaps Build Template was skipped`); | ||
} | ||
const template = artifacts[0]; | ||
let body = `<!-- commit-sha: ${pull_head_sha} -->\n`; | ||
body +=`## Download the template for this pull request: \n\n`; | ||
body += `> [!NOTE] | ||
> This is auto generated from [\`${{ github.workflow }}\`](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})\n`; | ||
body += `- via manual download: [${template.name}.zip](https://nightly.link/${owner}/${repo}/actions/artifacts/${template.id}.zip)\n`; | ||
body += `- via PROS Integrated Terminal: \n \`\`\` | ||
curl -o ${template.name}.zip https://nightly.link/${owner}/${repo}/actions/artifacts/${template.id}.zip; | ||
pros c fetch ${template.name}.zip; | ||
pros c apply ${template.name}; | ||
rm ${template.name}.zip; | ||
\`\`\``; | ||
core.info(`Review thread message body: \n${body}`); | ||
await upsertComment(owner, repo, issue_number, | ||
"nightly-link", old_body, body); | ||
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,26 @@ | ||
name: PROS Build Template | ||
|
||
on: | ||
push: | ||
branches: "**" | ||
pull_request: | ||
branches: "**" | ||
|
||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Run LemLib/pros-build | ||
id: test | ||
uses: LemLib/[email protected] | ||
|
||
- name: Upload Artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ steps.test.outputs.name }} | ||
path: ${{ github.workspace }}/template/* |
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,20 @@ | ||
name: test-clang-format | ||
|
||
on: | ||
push: | ||
branches: | ||
- '*' | ||
pull_request: | ||
|
||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: DoozyX/[email protected] | ||
with: | ||
source: './src/hardware ./include/hardware' | ||
extensions: 'hpp,cpp' | ||
clangFormatVersion: 18 |
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
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
Binary file not shown.
Binary file not shown.
Oops, something went wrong.