1name: Footprint Tracking
2
3# Run every 12 hours and on tags
4on:
5  schedule:
6    - cron: '50 1/12 * * *'
7  push:
8    paths:
9      - 'VERSION'
10      - '.github/workflows/footprint-tracking.yml'
11    branches:
12      - main
13      - v*-branch
14    tags:
15      # only publish v* tags, do not care about zephyr-v* which point to the
16      # same commit
17      - 'v*'
18
19concurrency:
20  group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.ref }}
21  cancel-in-progress: true
22
23jobs:
24  footprint-tracking:
25    runs-on:
26      group: zephyr-runner-v2-linux-x64-4xlarge
27    if: github.repository_owner == 'zephyrproject-rtos'
28    container:
29      image: ghcr.io/zephyrproject-rtos/ci-repo-cache:v0.27.4.20241026
30      options: '--entrypoint /bin/bash'
31    defaults:
32      run:
33        shell: bash
34    strategy:
35      fail-fast: false
36    env:
37      ZEPHYR_TOOLCHAIN_VARIANT: zephyr
38    steps:
39      - name: Apply container owner mismatch workaround
40        run: |
41          # FIXME: The owner UID of the GITHUB_WORKSPACE directory may not
42          #        match the container user UID because of the way GitHub
43          #        Actions runner is implemented. Remove this workaround when
44          #        GitHub comes up with a fundamental fix for this problem.
45          git config --global --add safe.directory ${GITHUB_WORKSPACE}
46
47      - name: Print cloud service information
48        run: |
49          echo "ZEPHYR_RUNNER_CLOUD_PROVIDER = ${ZEPHYR_RUNNER_CLOUD_PROVIDER}"
50          echo "ZEPHYR_RUNNER_CLOUD_NODE = ${ZEPHYR_RUNNER_CLOUD_NODE}"
51          echo "ZEPHYR_RUNNER_CLOUD_POD = ${ZEPHYR_RUNNER_CLOUD_POD}"
52
53      - name: Update PATH for west
54        run: |
55          echo "$HOME/.local/bin" >> $GITHUB_PATH
56
57      - name: Install packages
58        run: |
59          sudo apt-get update
60          sudo apt-get install -y python3-venv
61          pip install -U gitpython
62
63      - name: checkout
64        uses: actions/checkout@v4
65        with:
66          ref: ${{ github.event.pull_request.head.sha }}
67          fetch-depth: 0
68
69      - name: Environment Setup
70        run: |
71          echo "ZEPHYR_SDK_INSTALL_DIR=/opt/toolchains/zephyr-sdk-$( cat SDK_VERSION )" >> $GITHUB_ENV
72
73      - name: west setup
74        run: |
75          west init -l . || true
76          west config --global update.narrow true
77          west update 2>&1 1> west.update.log || west update 2>&1 1> west.update2.log
78
79      - name: Configure AWS Credentials
80        uses: aws-actions/configure-aws-credentials@v4
81        with:
82          aws-access-key-id: ${{ vars.AWS_TESTING_ACCESS_KEY_ID }}
83          aws-secret-access-key: ${{ secrets.AWS_TESTING_SECRET_ACCESS_KEY }}
84          aws-region: us-east-1
85
86      - name: Record Footprint
87        env:
88          BASE_REF: ${{ github.base_ref }}
89        run: |
90          export ZEPHYR_BASE=${PWD}
91          ./scripts/footprint/track.py  -p scripts/footprint/plan.txt
92
93      - name: Upload footprint data
94        run: |
95          python3 -m venv .venv
96          . .venv/bin/activate
97          pip install awscli
98          aws s3 sync  --quiet footprint_data/ s3://testing.zephyrproject.org/footprint_data/
99
100      - name: Transform Footprint data to Twister JSON reports
101        run: |
102          shopt -s globstar
103          export ZEPHYR_BASE=${PWD}
104          python3 ./scripts/footprint/pack_as_twister.py -vvv \
105            --plan ./scripts/footprint/plan.txt \
106            --test-name='name.feature' \
107            ./footprint_data/**/
108
109      - name: Upload to ElasticSearch
110        env:
111          ELASTICSEARCH_KEY: ${{ secrets.ELASTICSEARCH_KEY }}
112          ELASTICSEARCH_SERVER: "https://elasticsearch.zephyrproject.io:443"
113          ELASTICSEARCH_INDEX: ${{ vars.FOOTPRINT_TRACKING_INDEX }}
114        run: |
115          shopt -s globstar
116          pip install -U elasticsearch
117          run_date=`date --iso-8601=minutes`
118          python3 ./scripts/ci/upload_test_results_es.py -r ${run_date} \
119            --flatten footprint \
120            --flatten-list-names "{'children':'name'}" \
121            --transform "{ 'footprint_name': '^(?P<footprint_area>([^\/]+\/){0,2})(?P<footprint_path>([^\/]*\/)*)(?P<footprint_symbol>[^\/]*)$' }" \
122            --run-id "${{ github.run_id }}" \
123            --run-attempt "${{ github.run_attempt }}" \
124            --run-workflow "footprint-tracking:${{ github.event_name }}" \
125            --run-branch "${{ github.ref_name }}" \
126            -i ${ELASTICSEARCH_INDEX} \
127            ./footprint_data/**/twister_footprint.json
128        #
129