1 # This is a reusable workflow
3 name: Build artifacts and run tests
8 matrix_all_combinations:
9 description: "if matrix should have all combinations of targets and features"
14 description: "if built artifacts should be uploaded"
20 matrix_all_combinations:
21 description: "if matrix should have all combinations of targets and features"
25 description: "if built artifacts should be uploaded"
30 build-artifacts-and-run-tests:
31 runs-on: ${{ matrix.os || 'ubuntu-latest' }}
37 feature-unrar: ${{ inputs.matrix_all_combinations && fromJSON('[true, false]') || fromJSON('[false]')}}
38 feature-use-zlib: ${{ inputs.matrix_all_combinations && fromJSON('[true, false]') || fromJSON('[false]')}}
39 feature-use-zstd-thin: ${{ inputs.matrix_all_combinations && fromJSON('[true, false]') || fromJSON('[false]')}}
42 - x86_64-unknown-linux-gnu
43 - x86_64-pc-windows-gnu
44 - x86_64-pc-windows-msvc
45 - aarch64-pc-windows-msvc
48 - x86_64-unknown-linux-musl
49 - aarch64-unknown-linux-gnu
50 - aarch64-unknown-linux-musl
51 - armv7-unknown-linux-gnueabihf
52 - armv7-unknown-linux-musleabihf
56 - target: x86_64-pc-windows-gnu
58 - target: x86_64-pc-windows-msvc
60 - target: aarch64-pc-windows-msvc
62 - target: x86_64-apple-darwin
64 # targets that use cross
65 - target: x86_64-unknown-linux-musl
67 - target: aarch64-unknown-linux-gnu
69 - target: aarch64-unknown-linux-musl
71 - target: armv7-unknown-linux-gnueabihf
73 - target: armv7-unknown-linux-musleabihf
75 # features (unless `matrix_all_combinations` is true, we only run these on linux-gnu)
77 target: x86_64-unknown-linux-gnu
78 - feature-use-zlib: true
79 target: x86_64-unknown-linux-gnu
80 - feature-use-zstd-thin: true
81 target: x86_64-unknown-linux-gnu
85 uses: actions/checkout@v4
91 wget https://github.com/cross-rs/cross/releases/download/v0.2.4/cross-x86_64-unknown-linux-musl.tar.gz
92 tar xf cross-x86_64-unknown-linux-musl.tar.gz
95 echo CARGO=cross >> $GITHUB_ENV
97 - name: Concatenate features
102 if [[ "${{ matrix.feature-use-zlib }}" == true ]]; then FEATURES+=(use_zlib); fi
103 if [[ "${{ matrix.feature-use-zstd-thin }}" == true ]]; then FEATURES+=(use_zstd_thin); fi
104 if [[ "${{ matrix.feature-unrar }}" == true ]]; then FEATURES+=(unrar); fi
106 echo "FEATURES=${FEATURES[*]}" >> $GITHUB_OUTPUT
108 - name: Set up extra cargo flags
110 FEATURES: ${{steps.concat-features.outputs.FEATURES}}
113 FLAGS="--no-default-features"
114 if [[ -n "$FEATURES" ]]; then FLAGS+=" --features $FEATURES"; fi
115 echo "EXTRA_CARGO_FLAGS=$FLAGS" >> $GITHUB_ENV
119 rustup toolchain install stable --profile minimal -t ${{ matrix.target }}
121 - uses: Swatinem/rust-cache@v2
123 key: "${{ matrix.target }}-${{ matrix.feature-unrar }}-${{ matrix.feature-use-zstd-thin }}-${{ matrix.feature-unrar }}"
125 - name: Test on stable
126 # there's no way to run tests for ARM64 Windows for now
127 if: matrix.target != 'aarch64-pc-windows-msvc'
129 ${{ env.CARGO }} +stable test --profile fast --target ${{ matrix.target }} $EXTRA_CARGO_FLAGS
131 - name: Build release artifacts (binary and completions)
132 if: ${{ inputs.upload_artifacts }}
134 ${{ env.CARGO }} +stable build --release --target ${{ matrix.target }} $EXTRA_CARGO_FLAGS
136 OUCH_ARTIFACTS_FOLDER: artifacts
138 - name: Upload release artifacts
139 if: ${{ inputs.upload_artifacts }}
140 uses: actions/upload-artifact@v4
142 name: ouch-${{ matrix.target }}-${{ steps.concat-features.outputs.FEATURES }}
144 target/${{ matrix.target }}/release/ouch
145 target/${{ matrix.target }}/release/ouch.exe