Skip to content

Commit 81d7759

Browse files
committed
updates to license updater, improved cla handling
1 parent 34cbd08 commit 81d7759

File tree

6 files changed

+343
-143
lines changed

6 files changed

+343
-143
lines changed

β€Ž.github/actionlint.ymlβ€Ž

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# SPDX-FileCopyrightText: 2025 Knitli Inc. <knitli@knit.li>
2+
# SPDX-FileContributor: Adam Poulemanos <adam@knit.li>
3+
#
4+
# SPDX-License-Identifier: MIT OR Apache-2.0
5+
# ! Actionlint configuration file to ignore specific warnings
6+
paths:
7+
.github/workflows/cla.yml:
8+
ignore:
9+
- 'property "is_member" is not defined in object type {}'
10+
- >
11+
"github.event.pull_request.title" is potentially untrusted. avoid using it directly in inline scripts. instead, pass it through an environment variable. see https://docs.github.com/en/actions/security-for-github-actions/security-guides/security-hardening-for-github-actions for more details
12+
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
<!--
2-
SPDX-FileCopyrightText: 2025 Knitli Inc. <knitli@knit.li>
3-
SPDX-FileContributor: Adam Poulemanos <adam@knit.li>
4-
SPDX-License-Identifier: MIT OR Apache-2.0
5-
-->
6-
71
---
2+
# SPDX-FileCopyrightText: 2025 Knitli Inc. <knitli@knit.li>
3+
# SPDX-FileContributor: Adam Poulemanos <adam@knit.li>
4+
# SPDX-License-Identifier: MIT OR Apache-2.0
85
description: 'Code Analysis'
96
tools: ["codebase", "githubRepo", "context7", "sequential-thinking", ]
107
---
8+
# Expert Code Analyst
9+
1110
You're an experienced code analyst who specializes in identifying and resolving issues in codebases. Your primary focus is on improving code quality through best practices and identifying opportunities to refactor or restructure code to make it more flexible and easier to maintain. The user will ask you to research specific code, modules, or packages within the codebase. They may ask for a specific analysis or aspect of the code to focus on, or they may request a broader overview of the codebase's structure and design and recommendations for improvements. If you identify an opportunity for improving the code quality, you should provide actionable suggestions and code examples to help the user implement the improvements. Unless the user requests a different result, you should produce a report summarizing your findings with specific recommendations and references to specific code snippets by line number and filename.

β€Ž.github/workflows/ci.ymlβ€Ž

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
# SPDX-FileContributor: Adam Poulemanos <adam@knit.li>
33
#
44
# SPDX-License-Identifier: MIT OR Apache-2.0
5+
# ! GitHub Action to run the CI pipeline for Rust projects
6+
# ! This action is triggered on pushes and pull requests to the main and staging branches.
57
name: CI
68
on:
79
push:
8-
branches: [main, develop]
10+
branches: [main, staging]
911
pull_request:
10-
branches: [main, develop]
12+
branches: [main, staging]
1113
env:
1214
CARGO_TERM_COLOR: always
1315
jobs:
@@ -55,6 +57,7 @@ jobs:
5557
- name: Run hk ci workflow
5658
run: >
5759
"$HOME/.local/bin/mise" run ci
60+
5861
security_audit:
5962
name: Security Audit
6063
runs-on: ubuntu-latest

β€Ž.github/workflows/cla.ymlβ€Ž

Lines changed: 151 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# SPDX-FileContributor: Adam Poulemanos <adam@knit.li>
33
#
44
# SPDX-License-Identifier: MIT OR Apache-2.0
5+
# ! GitHub Action to check CLA signatures for Knitli repositories
6+
# ! This action is triggered on issue comments and pull request events.
57
name: "CLA Assistant"
68
on:
79
issue_comment:
@@ -14,32 +16,165 @@ permissions:
1416
pull-requests: write
1517
statuses: write
1618
jobs:
17-
CLAAssistant:
19+
set-pr-title:
20+
runs-on: ubuntu-latest
21+
if: >
22+
github.event_name == 'pull_request_target'
23+
24+
steps:
25+
- name: "Set PR Title"
26+
env:
27+
EV_TITLE: ${{ github.event.pull_request.title }}
28+
EV_BODY: ${{ github.event.pull_request.body }}
29+
run: |
30+
echo "${EV_TITLE}"
31+
set-issue-title:
32+
runs-on: ubuntu-latest
33+
if: >
34+
github.event_name == 'issue_comment'
35+
36+
steps:
37+
- name: "Set Issue Title"
38+
env:
39+
EV_TITLE: ${{ toJson(github.event.issue.title) }}
40+
EV_BODY: ${{ toJson(github.event.comment.body) }}
41+
run: |
42+
echo "${EV_TITLE}"
43+
check-cla:
44+
runs-on: ubuntu-latest
45+
steps:
46+
- name: "SetVariables"
47+
run: |
48+
# shellcheck disable=SC2296
49+
# This script sets up environment variables based on the GitHub event context.
50+
echo "Setting up variables..."
51+
repo="${{ github.repository }}"
52+
if [[ $repo != knitli* ]]; then
53+
echo "This action is only for Knitli repositories, exiting..."
54+
echo "looks like we're in a forked repository, exiting..."
55+
exit 0
56+
fi
57+
actor="${{ github.actor }}"
58+
echo "EV_ACTOR=$actor" >> "$GITHUB_ENV"
59+
event="${{ github.event_name }}"
60+
event="${event//_target/}"
61+
event="${event//_comment/}"
62+
if [[ $event == pull_request* ]]; then
63+
author="${{ github.event.pull_request.user.login }}"
64+
email="${{ github.event.pull_request.user.email }}"
65+
{
66+
echo "IS_PR=true";
67+
echo "IS_ISSUE=false";
68+
echo "EV_NUMBER=\"${{ github.event.pull_request.number }}\"";
69+
echo "EV_AUTHOR=\"$author\"";
70+
echo "EV_URL=\"${{ github.event.pull_request.html_url }}\"";
71+
echo "EV_EMAIL=\"$email\"";
72+
echo "IS_RECHECK=false";
73+
} >> "$GITHUB_ENV"
74+
else
75+
author="${{ github.event.issue.user.login }}"
76+
email="${{ github.event.issue.user.email }}"
77+
{
78+
echo "IS_PR=false";
79+
echo "IS_ISSUE=true";
80+
echo "EV_NUMBER=\"${{ github.event.issue.number }}\"";
81+
echo "EV_AUTHOR=\"$author\"";
82+
echo "EV_URL=\"${{ github.event.issue.html_url }}\"";
83+
echo "EV_EMAIL=\"$email\"";
84+
} >> "$GITHUB_ENV"
85+
if [[ "$EV_BODY" == 'recheck' || "$EV_BODY" == *'I read the contributors license agreement and I agree to it.'* ]]; then
86+
echo "IS_RECHECK=true" >> "$GITHUB_ENV"
87+
else
88+
echo "IS_RECHECK=false" >> "$GITHUB_ENV"
89+
fi
90+
fi
91+
# if it's a rerun of the action, then the author is the actor
92+
if [[ -z $author ]] || [[ $author != "$actor" ]]; then
93+
author="$actor"
94+
if [[ -z $email ]]; then
95+
email="${author}@users.noreply.github.com"
96+
fi
97+
echo "EV_AUTHOR=$author" >> "$GITHUB_ENV"
98+
echo "EV_EMAIL=$email" >> "$GITHUB_ENV"
99+
fi
100+
response=$(curl -s -o /dev/null -w "%{http_code}" \
101+
-H "Authorization: Bearer \"${{ secrets.GITHUB_TOKEN }}\"" \
102+
"https://api.github.com/orgs/knitli/members/$author")
103+
if [ "$response" == "204" ]; then
104+
echo "is_member=true" >> "$GITHUB_OUTPUT"
105+
echo "User $author is a member of Knitli."
106+
echo "MEMBER=true" >> "$GITHUB_ENV"
107+
else
108+
if [[ $email == *@knit.li || $email == *@knitli.com || $author == bashandbone ]]; then
109+
echo "MEMBER=true" >> "$GITHUB_ENV"
110+
echo "User $author has a Knitli email or is its founder. Provided email: $email"
111+
echo "is_member=true" >> "$GITHUB_OUTPUT"
112+
else
113+
echo "MEMBER=false" >> "$GITHUB_ENV"
114+
echo "is_member=false" >> "$GITHUB_OUTPUT"
115+
fi
116+
fi
117+
cla-assistant:
118+
needs: check-cla
119+
if: >
120+
(needs.check-cla.outputs.is_member && needs.check-cla.outputs.is_member == 'false' && needs.check-cla.outputs.is_member != 'true') || needs.check-cla.outputs.is_member == ''
121+
18122
runs-on: ubuntu-latest
19123
steps:
124+
- name: Debug
125+
run: |
126+
if [[ $DEBUG_ACTIONS == 'true' ]]; then
127+
printenv
128+
fi
20129
- name: "CLA Assistant"
21130
if: >
22-
(github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the contributors license agreement and I agree to it.') || github.event_name == 'pull_request_target'
131+
(env.IS_RECHECK && env.IS_PR) && (env.IS_RECHECK == 'true' || env.IS_PR == 'true')
23132
24133
uses: contributor-assistant/github-action@v2.6.1
25134
env:
26135
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27-
# the below token should have repo scope and must be manually added by you in the repository's secret
28-
# This token is required only if you have configured to store the signatures in a remote repository/organization
29-
# PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
30136
with:
31137
path-to-signatures: 'cla.json'
32-
path-to-document: 'https://github.com/knitli/thread/blob/main/CONTRIBUTORS_LICENSE_AGREEMENT.md' # e.g. a CLA or a DCO document
33-
# branch should not be protected
34-
branch: 'main'
35-
allowlist: bashandbone,codegen-sh[bot],dependabot[bot],github-actions[bot],actions-user,changeset-bot
36-
# the followings are the optional inputs - If the optional inputs are not given, then default values will be taken
37-
#remote-organization-name: enter the remote organization name where the signatures should be stored (Default is storing the signatures in the same repository)
38-
#remote-repository-name: enter the remote repository name where the signatures should be stored (Default is storing the signatures in the same repository)
138+
path-to-document: 'https://github.com/knitli/thread/blob/main/CONTRIBUTORS_LICENSE_AGREEMENT.md'
139+
branch: 'staging'
140+
allowlist: >
141+
bashandbone,codegen-sh[bot],dependabot[bot],github-actions[bot],actions-user,changeset-bot
142+
39143
create-file-commit-message: 'Adding file for tracking CLA signatures'
40-
signed-commit-message: '$contributorName signed πŸ–ŠοΈ the Thread 🧡 CLA in $owner/$repo#$pullRequestNo'
41-
custom-notsigned-prcomment: 'βœ‹ Hey $contributorName, πŸ›‘ thanks for your contribution! Before we can accept it, **we need you to sign our contributors license agreement (CLA)**. πŸ–ŠοΈ'
42-
custom-pr-sign-comment: 'I have read the [Thread contributors license agreement](https://github.com/knitli/thread/blob/main/CONTRIBUTORS_LICENSE_AGREEMENT.md) and I agree to it.'
43-
custom-allsigned-prcomment: 'πŸš€ GOOD TO GO. Everyone has agreed to the CLA. πŸ‘'
144+
signed-commit-message: >
145+
$env.EV_AUTHOR signed πŸ–ŠοΈ the Thread 🧡 CLA in [$env.GITHUB_REPOSITORY # $env.EV_NUMBER]($env.EV_URL)
146+
147+
custom-notsigned-prcomment: |
148+
βœ‹πŸ›‘ Hey $env.EV_AUTHOR,
149+
150+
## Thanks for your contribution to Thread!
151+
152+
### You need to agree to the CLA first... πŸ–ŠοΈ
153+
154+
Before we can accept your (awesome) contribution, **we need you to agree to our contributors license agreement (CLA)**. πŸ–ŠοΈ
155+
156+
### To agree to the CLA, please comment:
157+
> I read the contributors license agreement and I agree to it.
158+
Those words are important[^1], so please don't change them. πŸ˜‰
159+
160+
[^1]: Our bot needs those *exact* words to recognize that you agree to the CLA. If you want to add something else, please do so after those words. πŸ˜‰
161+
custom-pr-sign-comment: |
162+
$env.EV_AUTHOR, agrees to the Thread CLA.
163+
164+
$env.EV_AUTHOR acknowledges they read and agree to the [Thread contributors license agreement](https://github.com/knitli/thread/blob/main/CONTRIBUTORS_LICENSE_AGREEMENT.md).
165+
custom-allsigned-prcomment: |
166+
## πŸš€ GOOD TO GO. Everyone has agreed to the CLA. πŸ‘
167+
168+
### Thanks for your contribution to Thread! 🧡
169+
Your contribution is now ready to be merged[^1]. πŸŽ‰
170+
171+
### Maintainers: Ship this PR! πŸ“¦πŸš€
172+
173+
[^1]: If it passes the other CI checks, of course. πŸ˜‰ I'm just here for the legal stuff.
174+
# UNUSED OPTIONS
44175
#lock-pullrequest-aftermerge: false - if you don't want this bot to automatically lock the pull request after merging (default - true)
45176
#use-dco-flag: true - If you are using DCO instead of CLA
177+
#TODO: move the signatures to a remote repository
178+
#remote-organization-name: enter the remote organization name where the signatures should be stored (Default is storing the signatures in the same repository)
179+
#remote-repository-name: enter the remote repository name where the signatures should be stored (Default is storing the signatures in the same repository)
180+
# PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}

β€Žhk.pklβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ local linters = new Mapping<String, Step> {
3636
glob = List("*README", "*.{login,astro,bash,bash_logout,bashrc,browserlistrc,conf,config,csh,css,cts,fish,gitattributes,gitmodules,html,htmx,ini,j2,jinja,jinja2,json,json5,jsonc,jsonl,ksh,md,mdown,mdtext,mdtxt,mdwn,mdx,mk,mkd,mts,nix,nu,pkl,profile,py,quokka,rs,sass,scss,sh,sh,shellcheckrc,sql,sqlite,stylelintrc,svelte,tcsh,toml,ts,tsx,txt,yaml,yml,zlogin,zlogout,zprofile,zsh,zshenv,zshrc}", "*Dockerfile*", "*Makefile*", "*makefile*", "CHANGELOG*", "CODE_OF_CONDUCT*", "CONTRIBUTING*", "HACKING*", "README*", "SECURITY*", "SHARING")
3737
batch = true
3838
check = "reuse lint-file {{ files }}"
39-
fix = "./scripts/update-licenses.py --files {{ files }}"
39+
fix = "./scripts/update-licenses.py add {{ files }}"
4040
}
4141

4242

0 commit comments

Comments
Β (0)