From 3dc36f6d92acf9526bc8081410b5db394844825f Mon Sep 17 00:00:00 2001 From: simonsan <14062932+simonsan@users.noreply.github.com> Date: Mon, 18 Sep 2023 18:59:54 +0200 Subject: [PATCH] ci: add workflow to update public api fixtures Signed-off-by: simonsan <14062932+simonsan@users.noreply.github.com> --- .github/workflows/update-public-api.yml | 48 +++++++++++++++++++ tests/public_api.rs | 9 ++-- .../.gitkeep | 0 .../public-api_linux.txt | 0 .../public-api_win.txt | 0 5 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/update-public-api.yml rename tests/{public_api_data => public_api_fixtures}/.gitkeep (100%) rename tests/{public_api_data => public_api_fixtures}/public-api_linux.txt (100%) rename tests/{public_api_data => public_api_fixtures}/public-api_win.txt (100%) diff --git a/.github/workflows/update-public-api.yml b/.github/workflows/update-public-api.yml new file mode 100644 index 00000000..c553b3c9 --- /dev/null +++ b/.github/workflows/update-public-api.yml @@ -0,0 +1,48 @@ +name: Check release + +permissions: + id-token: write # Enable OIDC + pull-requests: write + contents: write + +on: + workflow_dispatch: + +env: + UPDATE_EXPECT: 1 + +jobs: + update-fixtures: + name: Update Public API fixtures + runs-on: ${{ matrix.job.os }} + strategy: + fail-fast: false + matrix: + rust: [stable] + job: + - os: macos-latest + - os: ubuntu-latest + - os: windows-latest + steps: + - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4 + + - uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1 + with: + profile: minimal + toolchain: stable + override: true + - uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2 + - uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 # v1 + with: + command: test + args: -r --test public_api -- --ignored + - name: Create Pull Request + uses: peter-evans/create-pull-request@v5 + with: + token: ${{ secrets.GITHUB_TOKEN }} + add-paths: "tests/public_api_fixtures" + commit-message: "Update Public API fixtures" + branch: "update-public-api-fixtures" + delete-branch: true + base: "main" + title: "Update Public API fixtures" diff --git a/tests/public_api.rs b/tests/public_api.rs index 08fa7f2b..fb3a60ff 100644 --- a/tests/public_api.rs +++ b/tests/public_api.rs @@ -30,9 +30,12 @@ fn public_api() { // Assert that the public API looks correct #[cfg(target_os = "windows")] - expect_test::expect_file!["public_api_data/public-api_win.txt"] + expect_test::expect_file!["public_api_fixtures/public-api_win.txt"] .assert_eq(&public_api.to_string()); - #[cfg(not(target_os = "windows"))] - expect_test::expect_file!["public_api_data/public-api_linux.txt"] + #[cfg(target_os = "unix")] + expect_test::expect_file!["public_api_fixtures/public-api_linux.txt"] + .assert_eq(&public_api.to_string()); + #[cfg(target_os = "macos")] + expect_test::expect_file!["public_api_fixtures/public-api_macos.txt"] .assert_eq(&public_api.to_string()); } diff --git a/tests/public_api_data/.gitkeep b/tests/public_api_fixtures/.gitkeep similarity index 100% rename from tests/public_api_data/.gitkeep rename to tests/public_api_fixtures/.gitkeep diff --git a/tests/public_api_data/public-api_linux.txt b/tests/public_api_fixtures/public-api_linux.txt similarity index 100% rename from tests/public_api_data/public-api_linux.txt rename to tests/public_api_fixtures/public-api_linux.txt diff --git a/tests/public_api_data/public-api_win.txt b/tests/public_api_fixtures/public-api_win.txt similarity index 100% rename from tests/public_api_data/public-api_win.txt rename to tests/public_api_fixtures/public-api_win.txt