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

ci(github): skip commit parity for bots #3521

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 1 addition & 17 deletions .github/workflows/pr-commit-parity.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,10 @@ jobs:
pr-commit-parity:
name: PR and Commit messages Parity
runs-on: ubuntu-22.04
if: "!contains('dependabot[bot]', github.event.pull_request.user.login)"
env:
ACCEPTABLE_SIMILARITY_RATIO: 0.9
steps:
- uses: actions/checkout@v3.1.0
- name: Install Indy SDK
run: >
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys CE7709D068DB5E88 \
&& sudo add-apt-repository "deb https://repo.sovrin.org/sdk/deb bionic stable" \
&& sudo apt-get update \
&& sudo apt-get install -y \
libindy \
libnullpay \
libvcx \
indy-cli \
&& sudo rm -f /etc/apt/sources.list.d/sovrin.list*
- name: Set up NodeJS ${{ env.NODEJS_VERSION }}
uses: actions/setup-node@v4.0.3
with:
node-version: ${{ env.NODEJS_VERSION }}
- run: npm run configure

- name: Execute pr-commit-parity script
run: node tools/pr-commit-parity.js ${{ github.event.pull_request.url }} "$ACCEPTABLE_SIMILARITY_RATIO"
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@
"sort-package-json": "1.57.0",
"source-map-loader": "4.0.1",
"stream-browserify": "3.0.0",
"string-similarity-js": "2.1.4",
"tap": "16.3.8",
"tape": "5.6.6",
"tape-promise": "4.0.0",
Expand Down
46 changes: 45 additions & 1 deletion tools/pr-commit-parity.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,48 @@
import { stringSimilarity } from "string-similarity-js";
// Levenshtein Distance string metric is used for calculating
// string similarity which changes from 0 to 1,
// for 1 being exactly the same
function levenshteinDistance(str1, str2) {
const len1 = str1.length;
const len2 = str2.length;
const dp = Array.from({ length: len1 + 1 }, () => Array(len2 + 1).fill(0));

for (let i = 0; i <= len1; i++) {
dp[i][0] = i;
}

for (let j = 0; j <= len2; j++) {
dp[0][j] = j;
}

for (let i = 1; i <= len1; i++) {
for (let j = 1; j <= len2; j++) {
if (str1[i - 1] === str2[j - 1]) {
dp[i][j] = dp[i - 1][j - 1];
} else {
dp[i][j] = Math.min(
dp[i - 1][j] + 1,
dp[i][j - 1] + 1,
dp[i - 1][j - 1] + 1,
);
}
}
}

return dp[len1][len2];
}

function stringSimilarity(str1, str2) {
const maxLen = Math.max(str1.length, str2.length);

if (maxLen === 0) {
return 100; // Both strings are empty
}

const distance = levenshteinDistance(str1, str2);
const similarity = ((maxLen - distance) / maxLen) * 100;

return parseFloat(similarity.toFixed(2) / 100);
}

export async function fetchJsonFromUrl(url) {
const fetchResponse = await fetch(url);
Expand Down
8 changes: 0 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11108,7 +11108,6 @@ __metadata:
sort-package-json: "npm:1.57.0"
source-map-loader: "npm:4.0.1"
stream-browserify: "npm:3.0.0"
string-similarity-js: "npm:2.1.4"
tap: "npm:16.3.8"
tape: "npm:5.6.6"
tape-promise: "npm:4.0.0"
Expand Down Expand Up @@ -49484,13 +49483,6 @@ __metadata:
languageName: node
linkType: hard

"string-similarity-js@npm:2.1.4":
version: 2.1.4
resolution: "string-similarity-js@npm:2.1.4"
checksum: 10/55063198f233aca8833d8429626d9fafdeb164e0fc6a66364a4d8f509df17d49f8a8a42e4096da60c53fe4586b1bace7098c0265da590fe4ec96c3a8ecb90f69
languageName: node
linkType: hard

"string-similarity@npm:^4.0.1":
version: 4.0.4
resolution: "string-similarity@npm:4.0.4"
Expand Down
Loading