Created
May 30, 2024 14:08
-
-
Save satorunooshie/7e1b6568bd5b18a26ec6608a3d5a1ff6 to your computer and use it in GitHub Desktop.
example of vim-startuptime GitHub Actions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: vim-startuptime | |
| on: [push, pull_request] | |
| env: | |
| GIST_TOKEN: ${{ secrets.GIST_TOKEN }} | |
| jobs: | |
| measure-speed: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Vim | |
| id: vim | |
| uses: thinca/action-setup-vim@v2 | |
| with: | |
| vim_version: 'head' | |
| vim_type: 'vim' | |
| cache: 'false' | |
| download: 'never' | |
| - name: Show Vim version | |
| run: | | |
| ${{ steps.vim.outputs.executable }} --version | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: 'stable' | |
| # disable cache as this repository does not have go.sum. | |
| cache: 'false' | |
| - name: Setup vim-startuptime | |
| run: | | |
| go install github.com/rhysd/vim-startuptime@latest | |
| - name: Setup .vimrc | |
| run: | | |
| cp .vimrc ~/.vimrc | |
| - name: Install Dependencies | |
| run: | | |
| git clone --depth 1 https://github.com/satorunooshie/pairscolorscheme.git | |
| mkdir -p ~/.vim/colors | |
| cp ./pairscolorscheme/colors/pairs.vim ~/.vim/colors/ | |
| - name: Run vim-startuptime | |
| run: | | |
| vim-startuptime -vimpath ${{ steps.vim.outputs.executable }} -count 300 -warmup 50 -script >> output.txt | |
| echo total_average_time=$(cat output.txt | grep 'Total Average:' | awk '{printf "%.2f %s", $3, $4}') >> $GITHUB_ENV | |
| - name: Update badge | |
| run: | | |
| json=$(echo "{\"files\":{\"vim-startuptime.json\":{\"content\":\"{\\\"schemaVersion\\\":1,\\\"style\\\":\\\"for-the-badge\\\",\\\"label\\\":\\\"startuptime\\\",\\\"message\\\":\\\"${{ env.total_average_time }}\\\",\\\"logoColor\\\":\\\"#019733\\\",\\\"color\\\":\\\"brightgreen\\\",\\\"namedLogo\\\":\\\"vim\\\"}\"}}}") | |
| curl -s -L \ | |
| -X PATCH \ | |
| -H "Accept: application/vnd.github+json" \ | |
| -H "Authorization: Bearer ${GIST_TOKEN}" \ | |
| -H "X-GitHub-Api-Version: 2022-11-28" \ | |
| https://api.github.com/gists/23f13f7ddec85107fb2357f08f03ab1e \ | |
| -d "$json" | |
| - name: Create GitHub Step Summary | |
| run: | | |
| echo '### Vim Startup Time Result 🚀' >> $GITHUB_STEP_SUMMARY | |
| echo "| AVERAGE | MAX | MIN | FILE |" >> $GITHUB_STEP_SUMMARY | |
| echo "|-----------|---------|---------|-------------|" >> $GITHUB_STEP_SUMMARY | |
| # extract the necessary lines from the output and process them in Markdown format. | |
| grep -E '^[[:space:]]*[0-9]' "output.txt" | while read -r line; do | |
| echo "$line" | |
| average=$(echo "$line" | awk '{print $1}') | |
| max=$(echo "$line" | awk '{print $2}') | |
| min=$(echo "$line" | awk '{print $3}' | sed 's/:$//') | |
| file=$(echo "$line" | awk '{$1=$2=$3=""; print $0}' | sed 's/^ *//') | |
| echo "| $average | $max | $min | $file |" >> $GITHUB_STEP_SUMMARY | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment