Skip to content

Commit 2ea7190

Browse files
committed
help find cargo
1 parent de3e1b0 commit 2ea7190

File tree

2 files changed

+117
-59
lines changed

2 files changed

+117
-59
lines changed

.github/workflows/build-template.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Build Rust Binary
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
directory:
7+
required: true
8+
type: string
9+
artifact-name:
10+
required: true
11+
type: string
12+
binary-path: # This will be something like 'target/release/espflash'
13+
required: true
14+
type: string
15+
repository:
16+
required: false
17+
type: string
18+
ref:
19+
required: false
20+
type: string
21+
22+
jobs:
23+
build:
24+
runs-on: ubuntu-22.04
25+
container:
26+
image: ubuntu:20.04
27+
28+
steps:
29+
- uses: actions/checkout@v4
30+
with:
31+
repository: ${{ inputs.repository || github.repository }}
32+
ref: ${{ inputs.ref || github.ref }}
33+
34+
- name: Install dependencies
35+
env:
36+
DEBIAN_FRONTEND: noninteractive
37+
run: apt-get update && apt-get -y install curl musl-tools pkg-config
38+
39+
- name: Setup Rust toolchain with musl target
40+
uses: actions-rs/toolchain@v1
41+
with:
42+
profile: minimal
43+
toolchain: stable
44+
target: x86_64-unknown-linux-musl
45+
override: true
46+
47+
- name: Build static binary ${{ inputs.artifact-name }} and copy to workspace
48+
env:
49+
RUSTFLAGS: "-C target-feature=+crt-static"
50+
run: |
51+
cargo build --release --target x86_64-unknown-linux-musl
52+
DESTINATION_DIR="${{ github.workspace }}/artifacts"
53+
mkdir -p "$DESTINATION_DIR"
54+
BINARY_NAME="$(basename ${{ inputs.binary-path }})" # Extracts 'xtask' from 'target/release/xtask'
55+
cp "${{ inputs.binary-path }}" "$DESTINATION_DIR/$BINARY_NAME"
56+
57+
echo "Successfully built and copied $BINARY_NAME to $DESTINATION_DIR/"
58+
ls -l "$DESTINATION_DIR/" # List the contents of the artifacts directory for verification
59+
working-directory: ${{ inputs.directory }} # This ensures cargo build and initial copy run in this directory
60+
61+
- uses: actions/upload-artifact@v4
62+
with:
63+
name: ${{ inputs.artifact-name }}
64+
# Now, the path is always relative to the workspace root and points to the copied binary
65+
path: artifacts/${{ inputs.artifact-name }}
66+
if-no-files-found: error

.github/workflows/hil.yml

Lines changed: 51 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -19,49 +19,33 @@ env:
1919
CARGO_TERM_COLOR: always
2020
RUST_LOG: debug
2121

22-
# Cancel any currently running workflows from the same PR, branch, or
23-
# tag when a new workflow is triggered.
24-
#
25-
# https://stackoverflow.com/a/66336834
2622
concurrency:
2723
cancel-in-progress: true
2824
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
2925

3026
jobs:
3127
build-espflash:
32-
name: Build espflash
33-
runs-on: ubuntu-22.04
34-
container:
35-
image: ubuntu:20.04
36-
37-
steps:
38-
- uses: actions/checkout@v4
39-
with:
40-
repository: ${{ github.event.inputs.repository || github.repository }}
41-
ref: ${{ github.event.inputs.branch || github.ref }}
42-
43-
- name: Install dependencies
44-
env:
45-
DEBIAN_FRONTEND: noninteractive
46-
run: apt-get update && apt-get -y install curl musl-tools pkg-config
47-
48-
- name: Install toolchain
49-
run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
50-
51-
- name: Build espflash
52-
run: $HOME/.cargo/bin/cargo build --release
53-
working-directory: espflash
54-
55-
- uses: actions/upload-artifact@v4
56-
with:
57-
name: espflash
58-
path: target/release/espflash
59-
if-no-files-found: error
28+
uses: ./.github/workflows/build-template.yml
29+
with:
30+
directory: espflash
31+
artifact-name: espflash
32+
binary-path: target/release/espflash
33+
repository: ${{ github.event.inputs.repository || github.repository }}
34+
ref: ${{ github.event.inputs.branch || github.ref }}
35+
36+
build-xtask:
37+
uses: ./.github/workflows/build-template.yml
38+
with:
39+
directory: xtask
40+
artifact-name: xtask
41+
binary-path: target/release/xtask
42+
repository: ${{ github.event.inputs.repository || github.repository }}
43+
ref: ${{ github.event.inputs.branch || github.ref }}
6044

6145
run-target:
6246
if: github.repository_owner == 'esp-rs'
6347
name: ${{ matrix.board.mcu }}${{ matrix.board.freq }}
64-
needs: build-espflash
48+
needs: [build-espflash, build-xtask]
6549
runs-on:
6650
[
6751
self-hosted,
@@ -99,43 +83,51 @@ jobs:
9983
run: |
10084
chmod +x espflash_app/espflash
10185
echo "$PWD/espflash_app" >> "$GITHUB_PATH"
86+
- uses: actions/download-artifact@v4
87+
with:
88+
name: xtask
89+
path: xtask_app
10290

91+
- name: Set up xtask binary
92+
run: |
93+
chmod +x xtask_app/xtask
94+
echo "$PWD/xtask_app" >> "$GITHUB_PATH"
10395
- name: Run all tests
104-
run: cargo xtask run-tests --chip ${{ matrix.board.mcu }} -t 60
96+
run: ./xtask_app/xtask run-tests --chip ${{ matrix.board.mcu }} -t 60
10597

106-
- name: board-info test
107-
run: cargo xtask run-tests --chip ${{ matrix.board.mcu }} -t 15 board-info
98+
# - name: board-info test
99+
# run: $HOME/.cargo/bin/cargo xtask run-tests --chip ${{ matrix.board.mcu }} -t 15 board-info
108100

109-
- name: flash test
110-
run: cargo xtask run-tests --chip ${{ matrix.board.mcu }} -t 90 flash
101+
# - name: flash test
102+
# run: $HOME/.cargo/bin/cargo xtask run-tests --chip ${{ matrix.board.mcu }} -t 90 flash
111103

112-
- name: monitor test
113-
run: cargo xtask run-tests --chip ${{ matrix.board.mcu }} -t 20 monitor
104+
# - name: monitor test
105+
# run: $HOME/.cargo/bin/cargo xtask run-tests --chip ${{ matrix.board.mcu }} -t 20 monitor
114106

115-
- name: erase-flash test
116-
run: cargo xtask run-tests --chip ${{ matrix.board.mcu }} -t 60 erase-flash
107+
# - name: erase-flash test
108+
# run: $HOME/.cargo/bin/cargo xtask run-tests --chip ${{ matrix.board.mcu }} -t 60 erase-flash
117109

118-
- name: save-image/write-bin test
119-
run: |
120-
cargo xtask run-tests --chip ${{ matrix.board.mcu }} -t 60 save-image_write-bin
110+
# - name: save-image/write-bin test
111+
# run:
112+
# $HOME/.cargo/bin/cargo xtask run-tests --chip ${{ matrix.board.mcu }} -t 60 save-image_write-bin
121113

122-
- name: erase-region test
123-
run: cargo xtask run-tests --chip ${{ matrix.board.mcu }} -t 60 erase-region
114+
# - name: erase-region test
115+
# run: $HOME/.cargo/bin/cargo xtask run-tests --chip ${{ matrix.board.mcu }} -t 60 erase-region
124116

125-
- name: hold-in-reset test
126-
run: cargo xtask run-tests --chip ${{ matrix.board.mcu }} -t 10 hold-in-reset
117+
# - name: hold-in-reset test
118+
# run: $HOME/.cargo/bin/cargo xtask run-tests --chip ${{ matrix.board.mcu }} -t 10 hold-in-reset
127119

128-
- name: reset test
129-
run: cargo xtask run-tests --chip ${{ matrix.board.mcu }} -t 10 reset
120+
# - name: reset test
121+
# run: $HOME/.cargo/bin/cargo xtask run-tests --chip ${{ matrix.board.mcu }} -t 10 reset
130122

131-
- name: checksum-md5 test
132-
run: cargo xtask run-tests --chip ${{ matrix.board.mcu }} -t 10 checksum-md5
123+
# - name: checksum-md5 test
124+
# run: $HOME/.cargo/bin/cargo xtask run-tests --chip ${{ matrix.board.mcu }} -t 10 checksum-md5
133125

134-
- name: list-ports test
135-
run: cargo xtask run-tests --chip ${{ matrix.board.mcu }} -t 10 list-ports
126+
# - name: list-ports test
127+
# run: $HOME/.cargo/bin/cargo xtask run-tests --chip ${{ matrix.board.mcu }} -t 10 list-ports
136128

137-
- name: write-bin test
138-
run: cargo xtask run-tests --chip ${{ matrix.board.mcu }} -t 30 write-bin
129+
# - name: write-bin test
130+
# run: $HOME/.cargo/bin/cargo xtask run-tests --chip ${{ matrix.board.mcu }} -t 30 write-bin
139131

140-
- name: read-flash test
141-
run: cargo xtask run-tests --chip ${{ matrix.board.mcu }} -t 60 read-flash
132+
# - name: read-flash test
133+
# run: $HOME/.cargo/bin/cargo xtask run-tests --chip ${{ matrix.board.mcu }} -t 60 read-flash

0 commit comments

Comments
 (0)