diff --git a/.github/workflows/README.md b/.github/workflows/README.md new file mode 100644 index 0000000..3cebc4c --- /dev/null +++ b/.github/workflows/README.md @@ -0,0 +1,9 @@ +The testing workflow is divided into three parts: + - `test-build.yml` is run on `ubuntu-latest` and contains source-related checks: + linters, formatters and verifying whether the sources match dist/ directory. + - `test-action.yml` contains simple, general integration tests of the action + that should be run on each platform. + - `test-inputs.yml` is run on `ubuntu-latest` and contains specific integration + tests checking whether the action inputs are processed properly. + +`setup-test-workspace` is a helper action that creates a workspace containing two crates: the test fork of `ref_slice` and a dummy crate that has no matching baseline version on `crates.io`. diff --git a/.github/workflows/setup-test-workspace/action.yml b/.github/workflows/setup-test-workspace/action.yml index 8496958..7497e06 100644 --- a/.github/workflows/setup-test-workspace/action.yml +++ b/.github/workflows/setup-test-workspace/action.yml @@ -1,4 +1,9 @@ name: Setup test workspace +inputs: + ref-slice-ref: + description: 'Reference of the ref_slice to checkout' + required: false + default: '' runs: using: 'composite' steps: @@ -6,7 +11,7 @@ runs: uses: actions/checkout@v3 with: repository: mgr0dzicki/cargo-semver-action-ref-slice - fetch-depth: 0 + ref: ${{ inputs.ref-slice-ref }} persist-credentials: true path: ref_slice - name: Create dummy crate diff --git a/.github/workflows/test-action.yml b/.github/workflows/test-action.yml index 5159abd..2c1ba31 100644 --- a/.github/workflows/test-action.yml +++ b/.github/workflows/test-action.yml @@ -23,22 +23,22 @@ jobs: name: Run tests runs-on: ${{ inputs.runs-on }} steps: - - name: Checkout the test repository + - name: Checkout the test repository and test with patch change and patch version bump uses: actions/checkout@v3 with: repository: mgr0dzicki/cargo-semver-action-ref-slice - fetch-depth: 0 + ref: patch_change persist-credentials: true - name: Checkout the action uses: actions/checkout@v3 with: path: action - - name: Checkout the test with patch change and patch version bump - run: git checkout patch_change - name: Run the action uses: ./action/ - name: Checkout the test with major change and patch version bump - run: git checkout major_change + run: | + git fetch origin major_change + git checkout major_change - name: Run the action (allowed to fail) id: action_major uses: ./action/ diff --git a/.github/workflows/test-inputs.yml b/.github/workflows/test-inputs.yml index 6531706..dfa3651 100644 --- a/.github/workflows/test-inputs.yml +++ b/.github/workflows/test-inputs.yml @@ -15,20 +15,18 @@ env: CARGO_TERM_COLOR: always jobs: - test-package: - name: Test input package + test-package-patch: + name: Test input package (patch change) runs-on: ubuntu-latest steps: - name: Checkout the action uses: actions/checkout@v3 with: path: action - - name: Setup the workspace + - name: Setup the workspace with ref_slice patch change uses: ./action/.github/workflows/setup-test-workspace - - name: Checkout the test with patch change and patch version bump - run: | - cd ref_slice - git checkout patch_change + with: + ref-slice-ref: patch_change - name: Run the action on ref_slice patch change uses: ./action/ with: @@ -42,10 +40,19 @@ jobs: run: | echo "Error! The action should have failed because of checking the dummy crate, but it has not!" exit 1 - - name: Checkout the test with major change and patch version bump - run: | - cd ref_slice - git checkout major_change + + test-package-major: + name: Test input package (major change) + runs-on: ubuntu-latest + steps: + - name: Checkout the action + uses: actions/checkout@v3 + with: + path: action + - name: Setup the workspace with ref_slice major change + uses: ./action/.github/workflows/setup-test-workspace + with: + ref-slice-ref: major_change - name: Run the action on ref_slice major change (allowed to fail) id: action_major uses: ./action/ @@ -79,20 +86,18 @@ jobs: with: verbose: true - test-manifest-path: - name: Test input manifest-path + test-manifest-path-patch: + name: Test input manifest-path (patch change) runs-on: ubuntu-latest steps: - name: Checkout the action uses: actions/checkout@v3 with: path: action - - name: Setup the workspace + - name: Setup the workspace with ref_slice patch change uses: ./action/.github/workflows/setup-test-workspace - - name: Checkout the test with patch change and patch version bump - run: | - cd ref_slice - git checkout patch_change + with: + ref-slice-ref: patch_change - name: Run the action on ref_slice patch change (Cargo.toml path) uses: ./action/ with: @@ -112,10 +117,19 @@ jobs: run: | echo "Error! The action should have failed because of checking the dummy crate, but it has not!" exit 1 - - name: Checkout the test with major change and patch version bump - run: | - cd ref_slice - git checkout major_change + + test-manifest-path-major: + name: Test input manifest-path (major change) + runs-on: ubuntu-latest + steps: + - name: Checkout the action + uses: actions/checkout@v3 + with: + path: action + - name: Setup the workspace with ref_slice major change + uses: ./action/.github/workflows/setup-test-workspace + with: + ref-slice-ref: major_change - name: Run the action on ref_slice major change (Cargo.toml path, allowed to fail) id: action_major_cargo_toml uses: ./action/