diff --git a/.github/workflows/all-tests-slow.yml b/.github/workflows/all-tests-slow.yml new file mode 100644 index 000000000..da08e150b --- /dev/null +++ b/.github/workflows/all-tests-slow.yml @@ -0,0 +1,17 @@ +name: Run tests for all combinations + +on: + schedule: + - cron: "0 0 1,15 * *" # biweekly + push: + branches: + - main + paths-ignore: + - "*.md" + +jobs: + run-tests-for-all-combinations: + uses: ./.github/workflows/build-artifacts-and-run-tests.yml + with: + matrix_all_combinations: true + upload_artifacts: false diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-artifacts-and-run-tests.yml similarity index 64% rename from .github/workflows/build-and-test.yml rename to .github/workflows/build-artifacts-and-run-tests.yml index 752db3294..788c7a1c2 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-artifacts-and-run-tests.yml @@ -1,22 +1,42 @@ -name: build-and-test +# This is a reusable workflow + +name: Build artifacts and run tests on: - push: - branches: - - main - tags: - - "[0-9]+.[0-9]+.[0-9]+" - pull_request: + workflow_dispatch: + inputs: + matrix_all_combinations: + description: "if matrix should have all combinations of targets and features" + type: boolean + required: true + default: true + upload_artifacts: + description: "if built artifacts should be uploaded" + type: boolean + required: true + default: true + workflow_call: + inputs: + matrix_all_combinations: + description: "if matrix should have all combinations of targets and features" + type: boolean + required: true + upload_artifacts: + description: "if built artifacts should be uploaded" + type: boolean + required: true jobs: - build: - name: build - runs-on: ${{ matrix.os }} + build-artifacts-and-run-tests: + runs-on: ${{ matrix.os || 'ubuntu-latest' }} env: CARGO: cargo strategy: fail-fast: false matrix: + feature-unrar: ${{ inputs.matrix_all_combinations && fromJSON('[true, false]') || fromJSON('[false]')}} + feature-use-zlib: ${{ inputs.matrix_all_combinations && fromJSON('[true, false]') || fromJSON('[false]')}} + feature-use-zstd-thin: ${{ inputs.matrix_all_combinations && fromJSON('[true, false]') || fromJSON('[false]')}} target: # native - x86_64-unknown-linux-gnu @@ -30,13 +50,8 @@ jobs: - aarch64-unknown-linux-musl - armv7-unknown-linux-gnueabihf - armv7-unknown-linux-musleabihf - feature-use-zlib: [true, false] - feature-use-zstd-thin: [true, false] - feature-unrar: [true, false] include: - # default runner - - os: ubuntu-latest # runner overrides - target: x86_64-pc-windows-gnu os: windows-latest @@ -57,6 +72,13 @@ jobs: use-cross: true - target: armv7-unknown-linux-musleabihf use-cross: true + # features (unless `matrix_all_combinations` is true, we only run these on linux-gnu) + - feature-unrar: true + target: x86_64-unknown-linux-gnu + - feature-use-zlib: true + target: x86_64-unknown-linux-gnu + - feature-use-zstd-thin: true + target: x86_64-unknown-linux-gnu steps: - name: Checkout @@ -77,9 +99,9 @@ jobs: shell: bash run: | FEATURES=() - if [[ ${{ matrix.feature-use-zlib }} == true ]]; then FEATURES+=(use_zlib); fi - if [[ ${{ matrix.feature-use-zstd-thin }} == true ]]; then FEATURES+=(use_zstd_thin); fi - if [[ ${{ matrix.feature-unrar }} == true ]]; then FEATURES+=(unrar); fi + if [[ "${{ matrix.feature-use-zlib }}" == true ]]; then FEATURES+=(use_zlib); fi + if [[ "${{ matrix.feature-use-zstd-thin }}" == true ]]; then FEATURES+=(use_zstd_thin); fi + if [[ "${{ matrix.feature-unrar }}" == true ]]; then FEATURES+=(unrar); fi IFS=',' echo "FEATURES=${FEATURES[*]}" >> $GITHUB_OUTPUT @@ -115,47 +137,10 @@ jobs: - name: Upload artifacts uses: actions/upload-artifact@v4 + if: ${{ inputs.upload_artifacts }} with: name: ouch-${{ matrix.target }}-${{ steps.concat-features.outputs.FEATURES }} path: | target/${{ matrix.target }}/release/ouch target/${{ matrix.target }}/release/ouch.exe artifacts/ - - clippy-rustfmt: - name: clippy-rustfmt - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: "Cargo: clippy, fmt" - run: | - rustup toolchain install stable --profile minimal -c clippy - rustup toolchain install nightly --profile minimal -c rustfmt - cargo +stable clippy -- -D warnings - cargo +stable clippy --tests -- -D warnings - cargo +nightly fmt -- --check - - github-release: - name: github-release - runs-on: ubuntu-latest - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') - needs: build - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Download artifacts - uses: dawidd6/action-download-artifact@v3 - with: - path: artifacts - - - name: Package release assets - run: scripts/package-release-assets.sh - - - name: Create release - uses: softprops/action-gh-release@v2 - with: - draft: true - files: release/ouch-* diff --git a/.github/workflows/draft-release-automatic-trigger.yml b/.github/workflows/draft-release-automatic-trigger.yml new file mode 100644 index 000000000..f007f8035 --- /dev/null +++ b/.github/workflows/draft-release-automatic-trigger.yml @@ -0,0 +1,35 @@ +name: Automatic trigger draft release + +on: + push: + tags: + - "[0-9]+.[0-9]+.[0-9]+" + +jobs: + call-workflow-build-artifacts-and-run-tests: + uses: ./.github/workflows/build-artifacts-and-run-tests.yml + with: + matrix_all_combinations: true + upload_artifacts: true + + automated-draft-release: + runs-on: ubuntu-latest + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') + needs: build-artifacts-and-run-tests + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Download artifacts + uses: dawidd6/action-download-artifact@v3 + with: + path: artifacts + + - name: Package release assets + run: scripts/package-release-assets.sh + + - name: Create release + uses: softprops/action-gh-release@v2 + with: + draft: true + files: release/ouch-* diff --git a/.github/workflows/create-draft-release-with-artifacts.yml b/.github/workflows/draft-release-manual-trigger.yml similarity index 89% rename from .github/workflows/create-draft-release-with-artifacts.yml rename to .github/workflows/draft-release-manual-trigger.yml index 0b46fa692..6e296feb7 100644 --- a/.github/workflows/create-draft-release-with-artifacts.yml +++ b/.github/workflows/draft-release-manual-trigger.yml @@ -1,4 +1,4 @@ -name: create-draft-release-with-artifacts +name: Manual trigger draft release on: workflow_dispatch: @@ -8,8 +8,7 @@ on: required: true jobs: - github-release: - name: github-release + create-draft-release-from-manual-trigger: runs-on: ubuntu-latest steps: - name: Checkout diff --git a/.github/workflows/pr-workflow.yml b/.github/workflows/pr-workflow.yml new file mode 100644 index 000000000..ec894590f --- /dev/null +++ b/.github/workflows/pr-workflow.yml @@ -0,0 +1,35 @@ +name: PR workflow + +on: + pull_request: + paths-ignore: + - "*.md" + +jobs: + rustfmt-check: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: "Cargo: fmt" + run: | + rustup toolchain install nightly --profile minimal -c rustfmt + cargo +nightly fmt -- --check + + clippy-checks: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: "Cargo: clippy" + run: | + rustup toolchain install stable --profile minimal -c clippy + cargo +stable clippy -- -D warnings + + build-and-test: + uses: ./.github/workflows/build-artifacts-and-run-tests.yml + with: + matrix_all_combinations: false + upload_artifacts: false