Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Jan 7, 2024
1 parent 2b07420 commit 28bf426
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 50 deletions.
120 changes: 70 additions & 50 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
push:
branches:
- main
- dev
- checkout
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
Expand All @@ -22,57 +22,77 @@ concurrency:
cancel-in-progress: true

jobs:
tidy:
uses: taiki-e/github-actions/.github/workflows/tidy.yml@main
# tidy:
# uses: taiki-e/github-actions/.github/workflows/tidy.yml@main

free-device-space:
strategy:
fail-fast: false
matrix:
os:
# https://github.com/actions/runner-images#available-images
- ubuntu-20.04
- ubuntu-22.04
- macos-11
- macos-12
- macos-13
- windows-2019
- windows-2022
runs-on: ${{ matrix.os }}
actions-checkout:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Run du -h
run: |
set -eEuxo pipefail
sudo du / -h -d1 2>/dev/null || true
sudo du /home -h -d2 || true
sudo du /opt -h -d2 || true
sudo du /usr -h -d2 || true
sudo du /usr/local/lib -h -d1 || true
sudo du /usr/local/share -h -d1 || true
sudo du /var -h -d1 || true
sudo du /var/lib -h -d1 || true
if: startsWith(matrix.os, 'ubuntu')
- uses: ./free-device-space
- name: Run du -h
run: |
set -eEuxo pipefail
sudo du / -h -d1 2>/dev/null || true
sudo du /home -h -d2 || true
sudo du /opt -h -d2 || true
sudo du /usr -h -d2 || true
sudo du /usr/local/lib -h -d1 || true
sudo du /usr/local/share -h -d1 || true
sudo du /var -h -d1 || true
sudo du /var/lib -h -d1 || true
if: startsWith(matrix.os, 'ubuntu')
- uses: taiki-e/github-actions/checkout@checkout
- uses: taiki-e/install-action@shellcheck
- uses: taiki-e/install-action@shfmt
- run: pip3 install yq
- run: git ls-files
- run: ./tools/tidy.sh

setup-docker:
checkout:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: ./setup-docker
- uses: taiki-e/github-actions/checkout@checkout
- uses: taiki-e/install-action@shellcheck
- uses: taiki-e/install-action@shfmt
- run: pip3 install yq
- run: git ls-files
- run: ./tools/tidy.sh

# free-device-space:
# strategy:
# fail-fast: false
# matrix:
# os:
# # https://github.com/actions/runner-images#available-images
# - ubuntu-20.04
# - ubuntu-22.04
# - macos-11
# - macos-12
# - macos-13
# - windows-2019
# - windows-2022
# runs-on: ${{ matrix.os }}
# steps:
# - uses: actions/checkout@v4
# with:
# persist-credentials: false
# - name: Run du -h
# run: |
# set -eEuxo pipefail
# sudo du / -h -d1 2>/dev/null || true
# sudo du /home -h -d2 || true
# sudo du /opt -h -d2 || true
# sudo du /usr -h -d2 || true
# sudo du /usr/local/lib -h -d1 || true
# sudo du /usr/local/share -h -d1 || true
# sudo du /var -h -d1 || true
# sudo du /var/lib -h -d1 || true
# if: startsWith(matrix.os, 'ubuntu')
# - uses: ./free-device-space
# - name: Run du -h
# run: |
# set -eEuxo pipefail
# sudo du / -h -d1 2>/dev/null || true
# sudo du /home -h -d2 || true
# sudo du /opt -h -d2 || true
# sudo du /usr -h -d2 || true
# sudo du /usr/local/lib -h -d1 || true
# sudo du /usr/local/share -h -d1 || true
# sudo du /var -h -d1 || true
# sudo du /var/lib -h -d1 || true
# if: startsWith(matrix.os, 'ubuntu')

# setup-docker:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# with:
# persist-credentials: false
# - uses: ./setup-docker
13 changes: 13 additions & 0 deletions checkout/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# checkout

GitHub Action for checking out a repository.
There is no stability guarantee for this action, since it's supposed to only be
used in infra managed by us.

## Usage

See [action.yml](action.yml)

```yaml
- uses: taiki-e/github-actions/checkout@main
```
11 changes: 11 additions & 0 deletions checkout/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: checkout
description: GitHub Action for checking out a repository.

# Note:
# - inputs.* should be manually mapped to INPUT_* due to https://github.com/actions/runner/issues/665
# - Use GITHUB_*/RUNNER_* instead of github.*/runner.* due to https://github.com/actions/runner/issues/2185
runs:
using: composite
steps:
- run: bash --noprofile --norc "${GITHUB_ACTION_PATH:?}/main.sh"
shell: bash
37 changes: 37 additions & 0 deletions checkout/main.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0 OR MIT
set -eEuo pipefail
IFS=$'\n\t'

g() {
local cmd="$1"
shift
IFS=' '
echo "::group::${cmd} $*"
IFS=$'\n\t'
"${cmd}" "$@"
}
retry() {
for i in {1..10}; do
if "$@"; then
return 0
else
sleep "${i}"
fi
done
"$@"
}

g git version

g git init
g git remote add origin "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}"

g git config --local gc.auto 0

g retry git -c protocol.version=2 fetch --no-tags --prune --no-recurse-submodules --depth=1 origin "+${GITHUB_SHA}:${GITHUB_REF}"

g retry git checkout --progress --force "${GITHUB_REF}"

wd=$(pwd)
g git config --global --add safe.directory "${wd}"

0 comments on commit 28bf426

Please sign in to comment.