Skip to content

Commit

Permalink
Refactor setup script timeout to 20 minutes for both Ubuntu and macOS (
Browse files Browse the repository at this point in the history
…#5)

* Refactor setup script timeout to 20 minutes for both Ubuntu and macOS

* Refactor setup script to enable Gatekeeper

* Refactor setup script to remove Gatekeeper enablement

* Refactor setup script to handle caching and downloading HackGenNerd Font

* Refactor setup script to handle caching and downloading HackGenNerd Font in Linux environment

* Refactor setup script to handle caching and downloading HackGenNerd Font in Linux environment

* Refactor setup script to fix wget command in Linux environment

* Refactor setup script to handle caching and downloading HackGenNerd Font in Linux environment

* Refactor setup script to remove unnecessary --cask flag when installing aws-vault in Linux environment

* Refactor setup script to handle unsupported OS when installing Google Chrome

* Refactor setup script to fix cache key for HackGenNerd Font in Linux environment

* Refactor setup script to cache and download HackGenNerd Font in Linux environment

* Refactor setup script to enable Gatekeeper on macOS
  • Loading branch information
tqer39 authored Oct 21, 2024
1 parent e706638 commit 1a8998d
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 10 deletions.
38 changes: 34 additions & 4 deletions .github/workflows/test-setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,47 @@ on:
- main
workflow_dispatch:

env:
HACKGEN_VERSION: "2.9.0"
DL_PATH: "$HOME/Downloads"

jobs:
test-ubuntu:
timeout-minutes: 10
timeout-minutes: 20
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-script
- uses: actions/checkout@v4
- name: Cache HackGenNerd Font
id: cache-hackgen-nf
uses: actions/cache@v4
with:
path: ${{ env.DL_PATH }}/HackGen_NF_v${{ env.HACKGEN_VERSION }}.zip
key: ${{ runner.os }}-hackgen-nf-${{ env.HACKGEN_VERSION }}
restore-keys: |
${{ runner.os }}-hackgen-nf-${{ env.HACKGEN_VERSION }}
- name: Download HackGenNerd Font
if: steps.cache-hackgen-nf.outputs.cache-hit != 'true'
run: |
wget -P "${{ env.DL_PATH }}" "https://github.com/yuru7/HackGen/releases/download/v${{ env.HACKGEN_VERSION }}/HackGen_NF_v${{ env.HACKGEN_VERSION }}.zip"
- name: Cache HackGen
id: cache-hackgen
uses: actions/cache@v4
with:
path: ${{ env.DL_PATH }}/HackGen_v${{ env.HACKGEN_VERSION }}.zip
key: ${{ runner.os }}-hackgen-${{ env.HACKGEN_VERSION }}
restore-keys: |
${{ runner.os }}-hackgen-${{ env.HACKGEN_VERSION }}
- name: Download HackGen
if: steps.cache-hackgen.outputs.cache-hit != 'true'
run: |
wget -P "${{ env.DL_PATH }}" "https://github.com/yuru7/HackGen/releases/download/v${{ env.HACKGEN_VERSION }}/HackGen_v${{ env.HACKGEN_VERSION }}.zip"
- uses: ./.github/actions/setup-script

test-macos:
timeout-minutes: 10
timeout-minutes: 20
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Enable Gatekeeper
run: sudo spctl --master-enable
- uses: ./.github/actions/setup-script
40 changes: 34 additions & 6 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,25 @@ fi
echo "aws --version: $(aws --version)"

# aws-vault
install_if_missing "aws-vault" "brew install aws-vault"
if ! command -v aws-vault &> /dev/null; then
echo "aws-vault がインストールされていません。インストールを試みます。"
if [[ "$OS_TYPE" == "Linux" ]]; then
brew install aws-vault
elif [[ "$OS_TYPE" == "Darwin" ]]; then
brew install --cask aws-vault
else
echo "❌ サポートされていないOSです。aws-vault のインストールをスキップします。"
fi

if ! command -v aws-vault &> /dev/null; then
echo "❌ aws-vault のインストールに失敗しました。手動でインストールしてください。"
exit 1
else
echo "✅ aws-vault のインストールが完了しました。"
fi
else
echo "✅ aws-vault は既にインストールされています。"
fi

# jq
install_if_missing "jq" "brew install jq"
Expand Down Expand Up @@ -438,6 +456,8 @@ if ! command -v google-chrome &> /dev/null; then
else
echo "✅ Google Chrome のインストールが完了しました。"
fi
else
echo "❌ サポートされていないOSです。Google Chrome のインストールをスキップします。"
fi
else
echo "✅ Google Chrome は既にインストールされています。"
Expand Down Expand Up @@ -523,15 +543,23 @@ if [[ "$OS_TYPE" == "Linux" ]]; then
HACKGEN_VERSION="2.9.0"
DL_PATH="$HOME/Downloads"

# HackGen_NF のダウンロードとインストール
wget -P "$DL_PATH" "https://github.com/yuru7/HackGen/releases/download/v${HACKGEN_VERSION}/HackGen_NF_v${HACKGEN_VERSION}.zip"
# CI のときは事前にダウンロードしてキャッシュしてるのでスキップ
if [ "$CI" == "true" ]; then
echo "CI環境で実行されているため、ダウンロードをスキップします。"
else
# HackGen_NF のダウンロードとインストール
wget -P "$DL_PATH" "https://github.com/yuru7/HackGen/releases/download/v${HACKGEN_VERSION}/HackGen_NF_v${HACKGEN_VERSION}.zip"
fi
unzip -o "${DL_PATH}/HackGen_NF_v${HACKGEN_VERSION}.zip" -d "$DL_PATH"
# ユーザーにインストール
mkdir -p "$HOME/.local/share/fonts"
cp -r "${DL_PATH}/HackGen_NF_v${HACKGEN_VERSION}/"* "$HOME/.local/share/fonts/"
# インストーラとディレクトリを削除
rm -rf "${DL_PATH}/HackGen_NF_v${HACKGEN_VERSION}"
rm -rf "${DL_PATH}/HackGen_v${HACKGEN_VERSION}.zip"

if [ "$CI" != "true" ]; then
# インストーラとディレクトリを削除
rm -rf "${DL_PATH}/HackGen_NF_v${HACKGEN_VERSION}"
rm -rf "${DL_PATH}/HackGen_v${HACKGEN_VERSION}.zip"
fi

# HackGen のダウンロードとインストール
wget -P "$DL_PATH" "https://github.com/yuru7/HackGen/releases/download/v${HACKGEN_VERSION}/HackGen_v${HACKGEN_VERSION}.zip"
Expand Down

0 comments on commit 1a8998d

Please sign in to comment.