-
-
Notifications
You must be signed in to change notification settings - Fork 7
179 lines (149 loc) · 5.92 KB
/
cleanup_coverage.yml
File metadata and controls
179 lines (149 loc) · 5.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#/
# @license Apache-2.0
#
# Copyright (c) 2025 The Stdlib Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#/
# Workflow name:
name: cleanup_coverage
# Workflow triggers:
on:
# Run the workflow on the first day of each week:
schedule:
- cron: '0 0 * * 1'
# Allow the workflow to be manually run:
workflow_dispatch:
# Global permissions:
permissions:
# Allow read-only access to the repository contents:
contents: read
# Workflow jobs:
jobs:
# Define a job for cleaning up unneeded coverage reports:
coverage:
# Define a display name:
name: 'Clean up unneeded coverage reports'
# Define the type of virtual host machine:
runs-on: ubuntu-latest
# Define the sequence of job steps...
steps:
# Checkout the repository:
- name: 'Checkout repository'
# Pin action to full length commit SHA
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
# Specify whether to remove untracked files before checking out the repository:
clean: true
# Limit clone depth to the most recent commit:
fetch-depth: 1
# Specify whether to download Git-LFS files:
lfs: false
# Avoid storing GitHub token in local Git configuration:
persist-credentials: false
timeout-minutes: 10
# Checkout development repository:
- name: 'Checkout development repository'
# Pin action to full length commit SHA
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
# Code development repository:
repository: 'stdlib-js/stdlib'
# Branch to checkout:
ref: 'develop'
# File path to checkout to:
path: './tmp'
# Specify whether to remove untracked files before checking out the repository:
clean: false
# Limit clone depth to the most recent commit:
fetch-depth: 1
# Token for accessing the repository:
token: ${{ secrets.STDLIB_BOT_FGPAT_REPO_READ }}
# Avoid storing GitHub token in local Git configuration:
persist-credentials: false
# Find and delete unneeded coverage directories:
- name: 'Find and delete unneeded coverage directories'
run: |
WORKING_DIR=$(pwd)
echo "Current working directory: $WORKING_DIR"
# Find all coverage directories:
find . \
\( -name .git -prune \) -o \
\( -name .github -prune \) -o \
\( -name etc -prune \) -o \
\( -name lib -prune \) -o \
\( -name public -prune \) -o \
\( -name server -prune \) -o \
\( -name src -prune \) -o \
\( -name tmp -prune \) -o \
\( -name tools -prune \) -o -type d -print | \
sed "s|^.\/||" | \
sed "s|^.$||" | \
sed -E 's/\/(benchmark|bin|data|docs|etc|examples|include|lib|scripts|src|test)(\/.*)?$//' | \
sort -u > coverage_dirs.txt
# Path to main package directory in development repository:
pkg_dir='./tmp/lib/node_modules/@stdlib'
# Extract all packages currently residing in `pkg_dir`:
find $pkg_dir -type d -print | \
sed "s|^$pkg_dir/||" | \
sed -E 's/\/(benchmark|bin|data|docs|etc|examples|include|lib|scripts|src|test)(\/.*)?$//' | \
sort -u > package_dirs.txt
# Find entries present in `coverage_dir` but not in `package_dirs`:
comm -23 coverage_dirs.txt package_dirs.txt > dirs_to_remove.txt
# Delete directories:
while IFS= read -r dir; do
if [ -z "$dir" ]; then
continue
fi
full_path="$WORKING_DIR/$dir"
if [ -d "$full_path" ]; then
echo "Removing directory: $full_path"
rm -r -- "$full_path"
else
echo "Warning: Directory not found: $full_path"
fi
done < dirs_to_remove.txt
# Perform clean-up
- name: 'Perform clean-up'
run: |
rm coverage_dirs.txt
rm package_dirs.txt
rm dirs_to_remove.txt
rm -rf ./tmp
# Import GPG key to sign commits:
- name: 'Import GPG key to sign commits'
# Pin action to full length commit SHA
uses: crazy-max/ghaction-import-gpg@cb9bde2e2525e640591a934b1fd28eef1dcaf5e5 # v6.2.0
with:
gpg_private_key: ${{ secrets.STDLIB_BOT_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.STDLIB_BOT_GPG_PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
# Create a pull request with the changes:
- name: 'Create pull request'
id: cpr
# Pin action to full length commit SHA
uses: peter-evans/create-pull-request@67ccf781d68cd99b580ae25a5c18a1cc84ffff1f # v7.0.6
with:
title: 'chore: cleanup coverage directories'
body: |
This PR
- removes all coverage directories that do not correspond anymore to packages in the main development repository.
commit-message: 'chore: cleanup coverage directories'
committer: 'stdlib-bot <82920195+stdlib-bot@users.noreply.github.com>'
signoff: true
token: ${{ secrets.STDLIB_BOT_PAT_REPO_WRITE }}
labels: |
automated-pr
branch: cleanup-coverage-directories
delete-branch: true