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: clean node_modules and target #7299

Merged
merged 5 commits into from
Sep 5, 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
52 changes: 52 additions & 0 deletions .github/actions/clean/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Clean Repository

inputs:
target:
required: true
type: string

runs:
using: composite
steps:
- name: Git Clean
shell: bash
run: |
git config --system core.longpaths true
rm -rf node_modules
git clean -ffdx -e target
git reset --hard HEAD

- name: Clean Large Directories by Size
if: ${{ !contains(inputs.target, 'windows') }}
shell: bash
run: |
if [ -d "target" ]; then
TARGET_SIZE=$(du -s target | awk '{print $1}')
MAX_SIZE=$((50 * 1024 * 1024))

echo "MAX_SIZE = $MAX_SIZE"
if [ "$TARGET_SIZE" -gt "$MAX_SIZE" ]; then
echo "`target` directory size is greater than 50GB, deleting..."
rm -rf target
else
echo "`target` directory size is within limits."
fi
fi

- name: Clean Large Directories by Time
if: ${{ contains(inputs.target, 'windows') }}
shell: bash
run: |
if [ -d "target" ]; then
TARGET_CREATION_TIME=$(powershell -Command "(Get-Item 'target').CreationTime")
TWO_WEEKS_AGO=$(date -d '2 weeks ago' +%s)

echo "TARGET_CREATION_TIME = $TARGET_CREATION_TIME"

if [ "$TARGET_CREATION_TIME" -lt "$TWO_WEEKS_AGO" ]; then
echo "'target' directory is older than 2 weeks, deleting..."
rm -rf target
else
echo "'target' directory is within 2 weeks."
fi
fi
39 changes: 12 additions & 27 deletions .github/workflows/reusable-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,11 @@ jobs:
ref: ${{ inputs.ref }}
clean: ${{ startsWith(runner.name, 'GitHub Actions') }}

- name: Git Clean
- name: Clean
if: ${{ !inputs.skipable && !startsWith(runner.name, 'GitHub Actions') }}
shell: bash
run: |
git config --system core.longpaths true
echo "rm -rf node_modules"
rm -rf node_modules
echo "git clean -ffdx -e target"
git clean -ffdx -e target
git reset --hard HEAD
uses: ./.github/actions/clean
with:
target: ${{ inputs.target }}

- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
Expand Down Expand Up @@ -225,16 +220,11 @@ jobs:
ref: ${{ inputs.ref }}
clean: ${{ startsWith(runner.name, 'GitHub Actions') }}

- name: Git Clean
- name: Clean
if: ${{ !startsWith(runner.name, 'GitHub Actions') }}
shell: bash
run: |
git config --system core.longpaths true
echo "rm -rf node_modules"
rm -rf node_modules
echo "git clean -ffdx -e target"
git clean -ffdx -e target
git reset --hard HEAD
uses: ./.github/actions/clean
with:
target: ${{ inputs.target }}

- name: Download bindings
uses: ./.github/actions/download-artifact
Expand Down Expand Up @@ -282,16 +272,11 @@ jobs:
ref: ${{ inputs.ref }}
clean: ${{ startsWith(runner.name, 'GitHub Actions') }}

- name: Git Clean
- name: Clean
if: ${{ !inputs.skipable && !startsWith(runner.name, 'GitHub Actions') }}
shell: bash
run: |
git config --system core.longpaths true
echo "rm -rf node_modules"
rm -rf node_modules
echo "git clean -ffdx -e target"
git clean -ffdx -e target
git reset --hard HEAD
uses: ./.github/actions/clean
with:
target: ${{ inputs.target }}

- name: Download bindings
if: ${{ !inputs.skipable }}
Expand Down
Loading