Skip to content

Commit 1ad8339

Browse files
committed
[skip ci] workflows: Update action configurations for improved dependency management
Refactor action.yml files to enhance clarity and maintainability of external dependencies, including Python and submodules. Signed-off-by: Chiho Sin <[email protected]>
1 parent d0058b0 commit 1ad8339

File tree

5 files changed

+52
-59
lines changed

5 files changed

+52
-59
lines changed

.github/actions/deps/external/action.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
name: Fetch external deps
22

33
inputs:
4-
action:
5-
required: false
6-
default: restore
7-
type: choice
8-
options:
9-
- cache
10-
- restore
11-
124
port:
135
required: false
146
default: none
@@ -54,8 +46,6 @@ runs:
5446
- name: Cache python dependencies
5547
if: inputs.port != 'espressif' && inputs.port != 'zephyr-cp'
5648
uses: ./.github/actions/deps/python
57-
with:
58-
action: ${{ inputs.action }}
5949
- name: Install python dependencies
6050
run: pip install -r requirements-dev.txt
6151
shell: bash

.github/actions/deps/ports/nordic/action.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,31 @@ name: Fetch nordic port deps
33
runs:
44
using: composite
55
steps:
6+
- name: Get current date
7+
id: date
8+
shell: bash
9+
run: echo "current_date=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
10+
- name: Cache nrfutil
11+
id: cache
12+
uses: runs-on/cache@v4
13+
with:
14+
path: |
15+
~/.local/bin
16+
key: |
17+
setup-nrfutil-${{ runner.os }}-${{ runner.arch }}-${{ steps.date.outputs.current_date }}
18+
restore-keys: |
19+
setup-nrfutil-${{ runner.os }}-${{ runner.arch }}-
620
- name: Get nrfutil 7+
21+
if: steps.cache.outputs.cache-hit != 'true'
722
run: |
823
wget https://files.nordicsemi.com/artifactory/swtools/external/nrfutil/executables/x86_64-unknown-linux-gnu/nrfutil
924
chmod +x nrfutil
1025
./nrfutil install nrf5sdk-tools
1126
mkdir -p $HOME/.local/bin
1227
mv nrfutil $HOME/.local/bin
28+
shell: bash
29+
- name: Setup nrfutil 7+
30+
run: |
1331
echo "$HOME/.local/bin" >> $GITHUB_PATH
1432
shell: bash
1533
- name: Print nrfutil version

.github/actions/deps/python/action.yml

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,35 @@
1-
name: Fetch python deps
2-
3-
inputs:
4-
action:
5-
description: The cache action to use
6-
required: false
7-
default: restore
8-
type: choice
9-
options:
10-
- cache
11-
- restore
1+
name: Setup Python with S3 cache
2+
description: Install and restore Python dependencies using S3 cache
123

134
runs:
145
using: composite
156
steps:
16-
- name: Cache python dependencies
17-
id: cache-python-deps
18-
if: inputs.action == 'cache'
19-
uses: actions/cache@v4
7+
- name: Setup Python
8+
uses: actions/setup-python@v5
209
with:
21-
path: .cp_tools
22-
key: ${{ runner.os }}-${{ env.pythonLocation }}-tools-cp-${{ hashFiles('requirements-dev.txt') }}
10+
python-version: 3.x
2311

24-
- name: Restore python dependencies
25-
id: restore-python-deps
26-
if: inputs.action == 'restore'
27-
uses: actions/cache/restore@v4
12+
- name: Gathering Python tools information
13+
id: python-info
14+
shell: bash
15+
run: |
16+
echo "python-version=$(python --version | cut -d' ' -f2)" >> $GITHUB_OUTPUT
17+
18+
- name: Cache Python tools
19+
uses: runs-on/cache@v4
20+
id: cache-python-deps
2821
with:
2922
path: .cp_tools
30-
key: ${{ runner.os }}-${{ env.pythonLocation }}-tools-cp-${{ hashFiles('requirements-dev.txt') }}
23+
key: setup-python-${{ runner.os }}-${{ runner.arch }}-python-${{ steps.python-info.outputs.python-version }}-tools-cp-${{ hashFiles('requirements-dev.txt') }}
24+
restore-keys: |
25+
setup-python-${{ runner.os }}-${{ runner.arch }}-python-${{ steps.python-info.outputs.python-version }}-tools-cp-
3126
3227
- name: Set up venv
33-
if: inputs.action == 'cache' && !steps.cache-python-deps.outputs.cache-hit
28+
if: ${{ !steps.cache-python-deps.outputs.cache-hit }}
3429
run: python -m venv .cp_tools
3530
shell: bash
3631

3732
- name: Activate venv
38-
if: inputs.action == 'cache' || (inputs.action == 'restore' && steps.restore-python-deps.outputs.cache-hit)
3933
run: |
4034
source .cp_tools/bin/activate
4135
echo >> $GITHUB_PATH "$PATH"

.github/actions/deps/submodules/action.yml

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: 'Fetch Submodules'
1+
name: Fetch Submodules with S3 cache
22

33
inputs:
44
target:
@@ -12,15 +12,6 @@ inputs:
1212
default: '["extmod/ulab", "lib/", "tools/"]'
1313
type: string
1414

15-
action:
16-
description: 'The cache action to use'
17-
required: false
18-
default: 'restore'
19-
type: choice
20-
options:
21-
- cache
22-
- restore
23-
2415
version:
2516
description: 'Whether to fetch tags to identify CP version'
2617
required: false
@@ -47,16 +38,7 @@ runs:
4738
shell: bash
4839

4940
- name: Cache submodules
50-
if: ${{ inputs.action == 'cache' }}
51-
uses: actions/cache@v4
52-
with:
53-
path: ".git/modules/\n${{ join(fromJSON(steps.create-submodule-status.outputs.submodules), '\n') }}"
54-
key: submodules-common-${{ hashFiles('submodule_status') }}
55-
enableCrossOsArchive: true
56-
57-
- name: Restore submodules
58-
if: ${{ inputs.action == 'restore' }}
59-
uses: actions/cache/restore@v4
41+
uses: runs-on/cache@v4
6042
with:
6143
path: ".git/modules/\n${{ join(fromJSON(steps.create-submodule-status.outputs.submodules), '\n') }}"
6244
key: submodules-common-${{ hashFiles('submodule_status') }}

.github/workflows/build-board-custom.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,19 @@ on:
3434

3535
run-name: ${{ inputs.board }}-${{ inputs.language }}-${{ inputs.version }}${{ inputs.flags != '' && '-custom' || '' }}${{ inputs.debug && '-debug' || '' }}
3636

37+
env:
38+
FOBE_S3_ARTIFACT_BUCKET: fobe-gars-artifact
39+
FOBE_S3_ARTIFACT_HOST: ${{ secrets.FOBE_GARS_S3_ENDPOINT_HOST }}
40+
FOBE_S3_ARTIFACT_PORT: ${{ secrets.FOBE_GARS_S3_ENDPOINT_PORT }}
41+
FOBE_S3_ARTIFACT_ACCESS_KEY: ${{ secrets.FOBE_GARS_S3_ACCESS_KEY }}
42+
FOBE_S3_ARTIFACT_SECRET_KEY: ${{ secrets.FOBE_GARS_S3_SECRET_KEY }}
43+
RUNS_ON_S3_BUCKET_CACHE: fobe-gars-cache
44+
RUNS_ON_AWS_REGION: cn-sounth-fobe-1
45+
AWS_ACCESS_KEY_ID: ${{ secrets.FOBE_GARS_S3_ACCESS_KEY }}
46+
AWS_SECRET_ACCESS_KEY: ${{ secrets.FOBE_GARS_S3_SECRET_KEY }}
47+
AWS_ENDPOINT_URL: "http://${{ secrets.FOBE_GARS_S3_ENDPOINT_HOST }}:${{ secrets.FOBE_GARS_S3_ENDPOINT_PORT }}"
48+
RUNS_ON_S3_FORCE_PATH_STYLE: "true"
49+
3750
jobs:
3851
build:
3952
runs-on: self-hosted
@@ -70,9 +83,7 @@ jobs:
7083
run: |
7184
> custom-build && git add custom-build
7285
- name: Set up python
73-
uses: actions/setup-python@v5
74-
with:
75-
python-version: 3.x
86+
uses: ./.github/actions/deps/python
7687
- name: Board to port
7788
id: board-to-port
7889
run: |
@@ -89,12 +100,10 @@ jobs:
89100
id: set-up-submodules
90101
uses: ./.github/actions/deps/submodules
91102
with:
92-
action: cache
93103
target: ${{ inputs.board }}
94104
- name: Set up external
95105
uses: ./.github/actions/deps/external
96106
with:
97-
action: cache
98107
port: ${{ steps.board-to-port.outputs.port }}
99108
- name: Set up mpy-cross
100109
if: steps.set-up-submodules.outputs.frozen == 'True'

0 commit comments

Comments
 (0)