Daily Lines of Code Report #169
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
| # Acknowledgement: This workflow is inspired by Ethrex Team (https://github.com/lambdaclass/ethrex) | |
| name: Daily Lines of Code Report | |
| on: | |
| schedule: | |
| # Every day at UTC midnight on weekdays | |
| - cron: "0 0 * * 1,2,3,4,5" | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| actions: write | |
| jobs: | |
| loc: | |
| name: Count loc and generate report | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout sources | |
| uses: actions/checkout@v4 | |
| - name: Setup Rust Environment | |
| uses: ./.github/actions/setup-rust | |
| - name: Find previous successful run | |
| id: find-previous-run | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| RUN_ID=$(gh run list -w daily_loc_report.yaml -s success -L 1 --json databaseId -q '.[0].databaseId') | |
| echo "run_id=$RUN_ID" >> $GITHUB_OUTPUT | |
| - name: Download previous loc report artifact | |
| id: download-artifact | |
| if: steps.find-previous-run.outputs.run_id != '' | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: ${{ github.event_name == 'workflow_dispatch' && 'loc-report-test' || 'loc-report' }} | |
| path: tooling/loc | |
| github-token: ${{ github.token }} | |
| run-id: ${{ steps.find-previous-run.outputs.run_id }} | |
| continue-on-error: true | |
| - name: Rename previous loc_report.json to loc_report.json.old | |
| if: steps.download-artifact.outcome == 'success' | |
| run: mv tooling/loc/loc_report.json tooling/loc/loc_report.json.old | |
| - name: Generate the loc report | |
| run: | | |
| cd tooling/loc && make loc | |
| - name: Upload loc report artifact | |
| if: success() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ github.event_name == 'workflow_dispatch' && 'loc-report-test' || 'loc-report' }} | |
| path: tooling/loc/loc_report.json | |
| retention-days: 7 | |
| - name: Post results in summary | |
| run: | | |
| echo "# lines of code report" >> $GITHUB_STEP_SUMMARY | |
| cat tooling/loc/loc_report_github.txt >> $GITHUB_STEP_SUMMARY | |
| - name: Post results to Slack | |
| env: | |
| SLACK_WEBHOOK: | |
| ${{ github.event_name == 'workflow_dispatch' && secrets.LOC_SLACK_WEBHOOK_TEST || secrets.LOC_SLACK_WEBHOOK }} | |
| run: | | |
| sh .github/scripts/publish_loc.sh "$SLACK_WEBHOOK" |