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

全ての workflow に name: を設定しつつ、reusable workflow のドキュメントを改善する #67

Merged
merged 10 commits into from
Aug 6, 2024

Conversation

masutaka
Copy link
Member

@masutaka masutaka commented Aug 5, 2024

変更概要

(1) 見栄えが良くないので、全ての workflow に name: を設定しました。また、my_*.yml の workflow は My prefix を付けました(参考)。

🔗 https://github.com/route06/actions/actions

My Workflows

(2) ドキュメント中の usage にも name: を設定し、見栄えの悪さがユーザーに伝播しないようにしました。

(3) 全体的にドキュメントを改善しました。

レビュー方法

f47f04d 以外は、変更後のファイルを確認するとレビューしやすいかと思います。

やらなかったこと

my_test.yml に以下のテストを導入し、(1)(2) が壊れた時に気付けるようにしたらどうだろう?と思いました。しかし、維持コストに見合わないと感じて止めました。

Details
diff --git a/.github/workflows/my_test.yml b/.github/workflows/my_test.yml
index dfdb203..b4fc7c7 100644
--- a/.github/workflows/my_test.yml
+++ b/.github/workflows/my_test.yml
@@ -32,3 +32,72 @@ jobs:
     steps:
       - uses: actions/checkout@v4
       - uses: ls-lint/action@1887e6c0e7f2dfa81a2d67591f0eb7782720026f # v2.2.3
+
+  own-lint:
+    runs-on: ubuntu-latest
+    timeout-minutes: 5
+    defaults:
+      run:
+        shell: bash
+        working-directory: .github/workflows
+    steps:
+      - uses: actions/checkout@v4
+      - name: "List workflows missing '^name:' line"
+        run: |
+          REGEXP='^name:'
+          missing_files=()
+
+          for file in *.yml; do
+            if ! grep -lq "$REGEXP" $file; then
+              missing_files+=("$file")
+            fi
+          done
+
+          if [ "${#missing_files[@]}" = 0 ]; then
+            echo "All workflows contain the '$REGEXP' line."
+            exit 0
+          fi
+
+          echo "The following workflows are missing the '$REGEXP' line:"
+          for file in "${missing_files[@]}"; do
+            echo "$file"
+          done
+
+          exit 1
+
+      - name: "List workflows missing '^# name:' line"
+        run: |
+          REGEXP='^# name:'
+
+          IGNORE_FILES=(
+            "codeql_core.yml"
+            "my_*.yml"
+          )
+
+          missing_files=()
+
+          for file in *.yml; do
+            # Skip ignored files
+            for ignore in "${IGNORE_FILES[@]}"; do
+              if [[ "$file" == $ignore ]]; then
+                echo "ignore: $file"
+                continue 2
+              fi
+            done
+
+            if ! grep -lq "$REGEXP" $file; then
+              missing_files+=("$file")
+            fi
+          done
+
+          if [ "${#missing_files[@]}" = 0 ]; then
+            echo "All workflows contain the '$REGEXP' line."
+            exit 0
+          fi
+
+          echo "The following workflows are missing the '$REGEXP' line:"
+          for file in "${missing_files[@]}"; do
+            echo "$file"
+          done
+
+          exit 1

@masutaka masutaka added documentation Improvements or additions to documentation maintenance labels Aug 5, 2024
@masutaka masutaka self-assigned this Aug 5, 2024
@masutaka masutaka marked this pull request as ready for review August 5, 2024 09:47
@masutaka masutaka requested a review from a team as a code owner August 5, 2024 09:47
Copy link
Contributor

@MH4GF MH4GF left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感謝です 🙌🏻

@masutaka masutaka added this pull request to the merge queue Aug 6, 2024
Merged via the queue into main with commit bd6eef3 Aug 6, 2024
3 checks passed
@masutaka masutaka deleted the add-name-to-workflows branch August 6, 2024 02:18
@route06-actions-ci route06-actions-ci bot mentioned this pull request Aug 6, 2024
@masutaka
Copy link
Member Author

masutaka commented Aug 6, 2024

(1) 見栄えが良くないので、全ての workflow に name: を設定しました。また、my_*.yml の workflow は My prefix を付けました(参考)。

きれいになりました。

🔗 https://github.com/route06/actions/actions

My Workflows(PR マージ後)

📝 一番上はマージされなかった #37 の履歴。今の設定だと履歴を 90 日保持するので、9/14 くらいに消えると思う。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation maintenance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants