Skip to content

Commit 3f5572b

Browse files
authored
Revert "build(jscpd): validate branch name before running CI (#6124)"
This reverts commit e300353.
1 parent e300353 commit 3f5572b

File tree

3 files changed

+86
-153
lines changed

3 files changed

+86
-153
lines changed
+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# # github actions: https://docs.github.com/en/actions/use-cases-and-examples/building-and-testing/building-and-testing-nodejs
2+
# # setup-node: https://github.com/actions/setup-node
3+
4+
# name: Copy-Paste Detection
5+
6+
# on:
7+
# pull_request:
8+
# branches: [master, feature/*, staging]
9+
10+
# jobs:
11+
# jscpd:
12+
# runs-on: ubuntu-latest
13+
# strategy:
14+
# matrix:
15+
# node-version: [18.x]
16+
# env:
17+
# NODE_OPTIONS: '--max-old-space-size=8192'
18+
19+
# steps:
20+
# - uses: actions/checkout@v4
21+
# with:
22+
# fetch-depth: 0
23+
24+
# - name: Use Node.js ${{ matrix.node-version }}
25+
# uses: actions/setup-node@v4
26+
# with:
27+
# node-version: ${{ matrix.node-version }}
28+
29+
# - name: Fetch fork upstream
30+
# run: |
31+
# git remote add forkUpstream https://github.com/${{ github.event.pull_request.head.repo.full_name }} # URL of the fork
32+
# git fetch forkUpstream # Fetch fork
33+
34+
# - name: Determine base and target branches for comparison.
35+
# run: |
36+
# echo "CURRENT_BRANCH=${{ github.head_ref }}" >> $GITHUB_ENV
37+
# echo "TARGET_BRANCH=${{ github.event.pull_request.base.ref }}" >> $GITHUB_ENV
38+
# - run: git diff --name-only origin/$TARGET_BRANCH forkUpstream/$CURRENT_BRANCH > diff_output.txt
39+
# - run: |
40+
# npm install -g jscpd
41+
42+
# - run: jscpd --config "$GITHUB_WORKSPACE/.github/workflows/jscpd.json"
43+
44+
# - if: always()
45+
# uses: actions/upload-artifact@v4
46+
# with:
47+
# name: unfiltered-jscpd-report
48+
# path: ./jscpd-report.json
49+
50+
# - name: Filter jscpd report for changed files
51+
# run: |
52+
# if [ ! -f ./jscpd-report.json ]; then
53+
# echo "jscpd-report.json not found"
54+
# exit 1
55+
# fi
56+
# echo "Filtering jscpd report for changed files..."
57+
# CHANGED_FILES=$(jq -R -s -c 'split("\n")[:-1]' diff_output.txt)
58+
# echo "Changed files: $CHANGED_FILES"
59+
# jq --argjson changed_files "$CHANGED_FILES" '
60+
# .duplicates | map(select(
61+
# (.firstFile?.name as $fname | $changed_files | any(. == $fname)) or
62+
# (.secondFile?.name as $sname | $changed_files | any(. == $sname))
63+
# ))
64+
# ' ./jscpd-report.json > filtered-jscpd-report.json
65+
# cat filtered-jscpd-report.json
66+
67+
# - name: Check for duplicates
68+
# run: |
69+
# if [ $(wc -l < ./filtered-jscpd-report.json) -gt 1 ]; then
70+
# echo "filtered_report_exists=true" >> $GITHUB_ENV
71+
# else
72+
# echo "filtered_report_exists=false" >> $GITHUB_ENV
73+
# fi
74+
# - name: upload filtered report (if applicable)
75+
# if: env.filtered_report_exists == 'true'
76+
# uses: actions/upload-artifact@v4
77+
# with:
78+
# name: filtered-jscpd-report
79+
# path: ./filtered-jscpd-report.json
80+
81+
# - name: Fail and log found duplicates.
82+
# if: env.filtered_report_exists == 'true'
83+
# run: |
84+
# cat ./filtered-jscpd-report.json
85+
# echo "Duplications found, failing the check."
86+
# exit 1

.github/workflows/lintbranch.js

-67
This file was deleted.

.github/workflows/node.js.yml

-86
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ jobs:
3232
- uses: actions/setup-node@v4
3333
with:
3434
node-version: '20'
35-
- name: Check Branch title
36-
env:
37-
BRANCH_NAME: ${{ github.head_ref }}
38-
run: |
39-
node "$GITHUB_WORKSPACE/.github/workflows/lintbranch.js" run "$BRANCH_NAME"
4035
- name: Check PR title
4136
run: |
4237
node "$GITHUB_WORKSPACE/.github/workflows/lintcommit.js"
@@ -60,87 +55,6 @@ jobs:
6055
- run: npm run testCompile
6156
- run: npm run lint
6257

63-
jscpd:
64-
needs: lint-commits
65-
if: ${{ github.event_name == 'pull_request'}}
66-
runs-on: ubuntu-latest
67-
strategy:
68-
matrix:
69-
node-version: [18.x]
70-
env:
71-
NODE_OPTIONS: '--max-old-space-size=8192'
72-
73-
steps:
74-
- uses: actions/checkout@v4
75-
with:
76-
fetch-depth: 0
77-
78-
- name: Use Node.js ${{ matrix.node-version }}
79-
uses: actions/setup-node@v4
80-
with:
81-
node-version: ${{ matrix.node-version }}
82-
83-
- name: Fetch fork upstream
84-
env:
85-
REPO_NAME: ${{ github.event.pull_request.head.repo.full_name }}
86-
run: |
87-
git remote add forkUpstream https://github.com/$REPO_NAME # URL of the fork
88-
git fetch forkUpstream # Fetch fork
89-
90-
- name: Compute git diff
91-
env:
92-
CURRENT_BRANCH: ${{ github.head_ref }}
93-
TARGET_BRANCH: ${{ github.event.pull_request.base.ref }}
94-
run: git diff --name-only origin/$TARGET_BRANCH forkUpstream/$CURRENT_BRANCH > diff_output.txt
95-
96-
- run: npm install -g jscpd
97-
98-
- run: jscpd --config "$GITHUB_WORKSPACE/.github/workflows/jscpd.json"
99-
100-
- if: always()
101-
uses: actions/upload-artifact@v4
102-
with:
103-
name: unfiltered-jscpd-report
104-
path: ./jscpd-report.json
105-
106-
- name: Filter jscpd report for changed files
107-
run: |
108-
if [ ! -f ./jscpd-report.json ]; then
109-
echo "jscpd-report.json not found"
110-
exit 1
111-
fi
112-
echo "Filtering jscpd report for changed files..."
113-
CHANGED_FILES=$(jq -R -s -c 'split("\n")[:-1]' diff_output.txt)
114-
echo "Changed files: $CHANGED_FILES"
115-
jq --argjson changed_files "$CHANGED_FILES" '
116-
.duplicates | map(select(
117-
(.firstFile?.name as $fname | $changed_files | any(. == $fname)) or
118-
(.secondFile?.name as $sname | $changed_files | any(. == $sname))
119-
))
120-
' ./jscpd-report.json > filtered-jscpd-report.json
121-
cat filtered-jscpd-report.json
122-
123-
- name: Check for duplicates
124-
run: |
125-
if [ $(wc -l < ./filtered-jscpd-report.json) -gt 1 ]; then
126-
echo "filtered_report_exists=true" >> $GITHUB_ENV
127-
else
128-
echo "filtered_report_exists=false" >> $GITHUB_ENV
129-
fi
130-
- name: upload filtered report (if applicable)
131-
if: env.filtered_report_exists == 'true'
132-
uses: actions/upload-artifact@v4
133-
with:
134-
name: filtered-jscpd-report
135-
path: ./filtered-jscpd-report.json
136-
137-
- name: Fail and log found duplicates.
138-
if: env.filtered_report_exists == 'true'
139-
run: |
140-
cat ./filtered-jscpd-report.json
141-
echo "Duplications found, failing the check."
142-
exit 1
143-
14458
macos:
14559
needs: lint-commits
14660
name: test macOS

0 commit comments

Comments
 (0)