From 5d18b189ec8c3f6dfbbb0224634110ef4c4baf93 Mon Sep 17 00:00:00 2001 From: Max Andreev Date: Mon, 19 Dec 2022 18:28:53 +0300 Subject: [PATCH 1/2] Run map file analyser through repository dispatch (#2148) * Add ripository dispatch * Fix mistakes --- .github/workflows/amap_analyse.yml | 40 +++--------------------------- .github/workflows/build.yml | 8 ++++++ 2 files changed, 12 insertions(+), 36 deletions(-) diff --git a/.github/workflows/amap_analyse.yml b/.github/workflows/amap_analyse.yml index 1340e4cde..12155e71a 100644 --- a/.github/workflows/amap_analyse.yml +++ b/.github/workflows/amap_analyse.yml @@ -1,13 +1,8 @@ name: 'Analyze .map file with Amap' on: - push: - branches: - - dev - - "release*" - tags: - - '*' - pull_request: + repository_dispatch: + types: [make_map_analyse] env: TARGETS: f7 @@ -15,24 +10,9 @@ env: jobs: amap_analyse: - if: ${{ !github.event.pull_request.head.repo.fork }} runs-on: [self-hosted,FlipperZeroMacShell] - timeout-minutes: 15 + timeout-minutes: 5 steps: - - name: 'Wait Build workflow' - uses: fountainhead/action-wait-for-check@v1.0.0 - id: wait-for-build - with: - token: ${{ secrets.GITHUB_TOKEN }} - checkName: 'main' - ref: ${{ github.event.pull_request.head.sha || github.sha }} - intervalSeconds: 20 - - - name: 'Check Build workflow status' - if: steps.wait-for-build.outputs.conclusion == 'failure' - run: | - exit 1 - - name: 'Decontaminate previous build leftovers' run: | if [ -d .git ]; then @@ -43,18 +23,6 @@ jobs: uses: actions/checkout@v3 with: fetch-depth: 0 - ref: ${{ github.event.pull_request.head.sha }} - - - name: 'Get commit details' - run: | - if [[ ${{ github.event_name }} == 'pull_request' ]]; then - TYPE="pull" - elif [[ "${{ github.ref }}" == "refs/tags/"* ]]; then - TYPE="tag" - else - TYPE="other" - fi - python3 scripts/get_env.py "--event_file=${{ github.event_path }}" "--type=$TYPE" - name: 'Make artifacts directory' run: | @@ -69,7 +37,7 @@ jobs: chmod 600 ./deploy_key; rsync -avzP \ -e 'ssh -p ${{ secrets.RSYNC_DEPLOY_PORT }} -i ./deploy_key' \ - ${{ secrets.RSYNC_DEPLOY_USER }}@${{ secrets.RSYNC_DEPLOY_HOST }}:"${{ secrets.RSYNC_DEPLOY_BASE_PATH }}${BRANCH_NAME}/" artifacts/; + ${{ secrets.RSYNC_DEPLOY_USER }}@${{ secrets.RSYNC_DEPLOY_HOST }}:"${{ secrets.RSYNC_DEPLOY_BASE_PATH }}${{ github.event.client_payload.branch_name }}/" artifacts/; rm ./deploy_key; - name: 'Make .map file analyze' diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2de0e57c3..e81d325e9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -98,6 +98,14 @@ jobs: artifacts/ ${{ secrets.RSYNC_DEPLOY_USER }}@${{ secrets.RSYNC_DEPLOY_HOST }}:"${{ secrets.RSYNC_DEPLOY_BASE_PATH }}${BRANCH_NAME}/"; rm ./deploy_key; + - name: 'Trigger map file analyser' + if: ${{ !github.event.pull_request.head.repo.fork }} + uses: peter-evans/repository-dispatch@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + event-type: make_map_analyse + client-payload: '{"branch_name": "${{steps.names.outputs.branch_name}}"}' + - name: 'Trigger update server reindex' if: ${{ !github.event.pull_request.head.repo.fork }} run: curl -X POST -F 'key=${{ secrets.REINDEX_KEY }}' ${{ secrets.REINDEX_URL }} From ef7052fbad5e776c09ca6df40517d013e02476d6 Mon Sep 17 00:00:00 2001 From: Max Andreev Date: Mon, 19 Dec 2022 19:42:06 +0300 Subject: [PATCH 2/2] Fix new amap workflow (#2151) * Fix amap workflow * get_env.py * Fix amap_analyse.yml --- .github/workflows/amap_analyse.yml | 14 ++++++++++++-- .github/workflows/build.yml | 14 ++++++++++++-- scripts/get_env.py | 9 +++++++-- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/.github/workflows/amap_analyse.yml b/.github/workflows/amap_analyse.yml index 12155e71a..7e78dc980 100644 --- a/.github/workflows/amap_analyse.yml +++ b/.github/workflows/amap_analyse.yml @@ -24,6 +24,16 @@ jobs: with: fetch-depth: 0 + - name: 'Get commit details' + run: | + export COMMIT_HASH=${{ github.event.client_payload.commit_hash }} + export COMMIT_MSG=${{ github.event.client_payload.commit_msg }} + export BRANCH_NAME=${{ github.event.client_payload.branch_name }} + if [[ ${{ github.event.client_payload.event_type }} == "pr" ]]; then + export PULL_ID=${{ github.event.client_payload.pull_id }} + export PULL_NAME=${{ github.event.client_payload.pull_name }} + fi + - name: 'Make artifacts directory' run: | rm -rf artifacts @@ -43,7 +53,7 @@ jobs: - name: 'Make .map file analyze' run: | cd artifacts/ - /Applications/amap/Contents/MacOS/amap -f "flipper-z-f7-firmware-${SUFFIX}.elf.map" + /Applications/amap/Contents/MacOS/amap -f flipper-z-f7-firmware-${{ github.event.client_payload.suffix }}.elf.map - name: 'Upload report to DB' run: | @@ -67,5 +77,5 @@ jobs: ${{ secrets.AMAP_MARIADB_HOST }} \ ${{ secrets.AMAP_MARIADB_PORT }} \ ${{ secrets.AMAP_MARIADB_DATABASE }} \ - artifacts/flipper-z-f7-firmware-$SUFFIX.elf.map.all + artifacts/flipper-z-f7-firmware-${{ github.event.client_payload.suffix }}.elf.map.all diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e81d325e9..52d4626d8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -99,12 +99,22 @@ jobs: rm ./deploy_key; - name: 'Trigger map file analyser' - if: ${{ !github.event.pull_request.head.repo.fork }} + if: ${{ (github.event_name != 'pull_request') + && !github.event.pull_request.head.repo.fork }} uses: peter-evans/repository-dispatch@v2 with: token: ${{ secrets.GITHUB_TOKEN }} event-type: make_map_analyse - client-payload: '{"branch_name": "${{steps.names.outputs.branch_name}}"}' + client-payload: '{"branch_name": "${{steps.names.outputs.branch_name}}", "commit_hash": "${{steps.names.outputs.commit_hash}}", "commit_msg": "${{steps.names.outputs.commit_msg}}", "event_type": "push"}' + + - name: 'Trigger map file analyser' + if: ${{ (github.event_name == 'pull_request') + && !github.event.pull_request.head.repo.fork }} + uses: peter-evans/repository-dispatch@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + event-type: make_map_analyse + client-payload: '{"branch_name": "${{steps.names.outputs.branch_name}}", "commit_hash": "${{steps.names.outputs.commit_hash}}", "commit_msg": "${{steps.names.outputs.commit_msg}}", "pull_id": "${{steps.names.outputs.pull_id}}", "pull_name": "${{steps.names.outputs.pull_name}}", "event_type": "pr"}' - name: 'Trigger update server reindex' if: ${{ !github.event.pull_request.head.repo.fork }} diff --git a/scripts/get_env.py b/scripts/get_env.py index e2da6eda5..c87de47a3 100644 --- a/scripts/get_env.py +++ b/scripts/get_env.py @@ -89,13 +89,18 @@ def add_envs(data, gh_env_file, gh_out_file, args): add_env("BRANCH_NAME", data["branch_name"], gh_env_file) add_env("DIST_SUFFIX", data["suffix"], gh_env_file) add_env("WORKFLOW_BRANCH_OR_TAG", data["branch_name"], gh_env_file) - add_set_output_var("branch_name", data["branch_name"], gh_out_file) + add_set_output_var("commit_msg", data["commit_comment"], gh_out_file) + add_set_output_var("commit_hash", data["commit_hash"], gh_out_file) add_set_output_var("commit_sha", data["commit_sha"], gh_out_file) - add_set_output_var("default_target", os.getenv("DEFAULT_TARGET"), gh_out_file) add_set_output_var("suffix", data["suffix"], gh_out_file) + add_set_output_var("branch_name", data["branch_name"], gh_out_file) + add_set_output_var("dist_suffix", data["suffix"], gh_out_file) + add_set_output_var("default_target", os.getenv("DEFAULT_TARGET"), gh_out_file) if args.type == "pull": add_env("PULL_ID", data["pull_id"], gh_env_file) add_env("PULL_NAME", data["pull_name"], gh_env_file) + add_set_output_var("pull_id", data["pull_id"], gh_out_file) + add_set_output_var("pull_name", data["pull_name"], gh_out_file) def main():