From a77cd3fd2724ddc8a534cac3de0627242379e7ae Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 4 Apr 2025 12:20:48 +0200 Subject: [PATCH 1/6] experiment workflow --- .github/workflows/early_runners.yml | 143 ++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 .github/workflows/early_runners.yml diff --git a/.github/workflows/early_runners.yml b/.github/workflows/early_runners.yml new file mode 100644 index 00000000..5da414b4 --- /dev/null +++ b/.github/workflows/early_runners.yml @@ -0,0 +1,143 @@ +name: Try Out Earlier Runners + +on: + push: + branches: + - "early-runners" + +permissions: + contents: write + +env: + # Need these guys for cross-compilation + CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc + CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER: aarch64-linux-gnu-gcc + +jobs: + # windows does not run git cliff so we need to do it here + extract_version: + name: Extract Version + runs-on: ubuntu-latest + outputs: + version: ${{ steps.set_version.outputs.version }} + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up git-cliff + uses: kenji-miyake/setup-git-cliff@v1 + + - name: Set version name + id: set_version + run: echo "version=$(git cliff --bumped-version)" >> "$GITHUB_OUTPUT" + + build_and_test: + name: Build & Test for ${{ matrix.config.target }} + needs: extract_version + strategy: + matrix: + config: + - { os: ubuntu-20.04, target: x86_64-unknown-linux-gnu } + - { os: ubuntu-20.04, target: aarch64-unknown-linux-gnu } + - { os: macos-14, target: x86_64-apple-darwin } + - { os: macos-14, target: aarch64-apple-darwin } + - { os: windows-2022, target: x86_64-pc-windows-msvc } + - { os: windows-2022, target: aarch64-pc-windows-msvc } + + runs-on: ${{ matrix.config.os }} + + outputs: + artifact_url: ${{ steps.upload-artifacts.outputs.artifact-url }} + + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + target: ${{ matrix.config.target }} + + - uses: Swatinem/rust-cache@v2 + id: rust-cache + + # The Aarch64 Linux is a special snowflake, we need to install its toolchain + - name: Install arm64 toolchain + if: matrix.config.target == 'aarch64-unknown-linux-gnu' + run: | + sudo apt-get update + sudo apt-get install -y gcc-aarch64-linux-gnu + + # running containers via `services` only works on linux + # https://github.com/actions/runner/issues/1866 + - name: ๐Ÿ˜ Setup postgres + uses: ikalnytskyi/action-setup-postgres@v7 + + - name: ๐Ÿงช Run Tests + run: cargo test --release + env: + DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres + + - name: ๐Ÿ› ๏ธ Run Build + run: cargo build -p pgt_cli --release --target ${{ matrix.config.target }} + env: + # Strip all debug symbols from the resulting binaries + RUSTFLAGS: "-C strip=symbols -C codegen-units=1" + # Inline the version in the CLI binary + PGT_VERSION: ${{ needs.extract_version.outputs.version }} + + # windows is a special snowflake too, it saves binaries as .exe + - name: ๐Ÿ‘ฆ Name the Binary + if: matrix.config.os == 'windows-latest' + run: | + mkdir dist + cp target/${{ matrix.config.target }}/release/postgrestools.exe ./dist/postgrestools_${{ matrix.config.target }} + - name: ๐Ÿ‘ฆ Name the Binary + if: matrix.config.os != 'windows-latest' + run: | + mkdir dist + cp target/${{ matrix.config.target }}/release/postgrestools ./dist/postgrestools_${{ matrix.config.target }} + + # It is not possible to return the artifacts from the matrix jobs individually: Matrix outputs overwrite each other. + # A common workaround is to upload and download the resulting artifacts. + - name: ๐Ÿ‘† Upload Artifacts + id: upload-artifacts + uses: actions/upload-artifact@v4 + with: + name: postgrestools_${{ matrix.config.target }} + path: ./dist/postgrestools_* + # The default compression level is 6; this took the binary down from 350 to 330MB. + # It is recommended to use a lower level for binaries, since the compressed result is not much smaller, + # and the higher levels of compression take much longer. + compression-level: 2 + if-no-files-found: error + + add-pr-comment: + runs-on: ubuntu-latest + needs: build_and_test # make sure that tests & build work correctly + steps: + - name: Checkout Repo + uses: actions/checkout@v4 + with: + # we need all commits to create a changelog + fetch-depth: 0 + + - name: Make Artifacts Dir + run: mkdir artifacts + + - name: ๐Ÿ‘‡ Download Artifacts + uses: actions/download-artifact@v4 + id: download + with: + merge-multiple: true + path: artifacts + pattern: postgrestools_* + + - name: Zip 'Em Up + run: zip -r artifacts.zip artifacts + + - name: Add PR Comment + uses: thollander/actions-comment-pull-request@v3 + with: + file-path: artifacts.zip From 5e5c2fbc398c767855f6dbd994d400bae071c7a6 Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 4 Apr 2025 12:37:20 +0200 Subject: [PATCH 2/6] release debug flag --- .github/workflows/early_runners.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/early_runners.yml b/.github/workflows/early_runners.yml index 5da414b4..e3f71190 100644 --- a/.github/workflows/early_runners.yml +++ b/.github/workflows/early_runners.yml @@ -12,6 +12,7 @@ env: # Need these guys for cross-compilation CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER: aarch64-linux-gnu-gcc + CARGO_PROFILE_RELEASE_BUILD_OVERRIDE_DEBUG: true jobs: # windows does not run git cliff so we need to do it here From e937c4c15789a79c60b9d6a480bfb65f52d9ea2c Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 4 Apr 2025 12:49:45 +0200 Subject: [PATCH 3/6] try 22 --- .github/workflows/early_runners.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/early_runners.yml b/.github/workflows/early_runners.yml index e3f71190..ce081398 100644 --- a/.github/workflows/early_runners.yml +++ b/.github/workflows/early_runners.yml @@ -40,8 +40,8 @@ jobs: strategy: matrix: config: - - { os: ubuntu-20.04, target: x86_64-unknown-linux-gnu } - - { os: ubuntu-20.04, target: aarch64-unknown-linux-gnu } + - { os: ubuntu-22.04, target: x86_64-unknown-linux-gnu } + - { os: ubuntu-22.04, target: aarch64-unknown-linux-gnu } - { os: macos-14, target: x86_64-apple-darwin } - { os: macos-14, target: aarch64-apple-darwin } - { os: windows-2022, target: x86_64-pc-windows-msvc } From bd4e0e3a757bbee358d314e6eddbb9f8aeeb75ee Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 4 Apr 2025 13:15:45 +0200 Subject: [PATCH 4/6] dang --- .github/workflows/early_runners.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/early_runners.yml b/.github/workflows/early_runners.yml index ce081398..7f376d8e 100644 --- a/.github/workflows/early_runners.yml +++ b/.github/workflows/early_runners.yml @@ -90,12 +90,12 @@ jobs: # windows is a special snowflake too, it saves binaries as .exe - name: ๐Ÿ‘ฆ Name the Binary - if: matrix.config.os == 'windows-latest' + if: matrix.config.os == 'windows-2022' run: | mkdir dist cp target/${{ matrix.config.target }}/release/postgrestools.exe ./dist/postgrestools_${{ matrix.config.target }} - name: ๐Ÿ‘ฆ Name the Binary - if: matrix.config.os != 'windows-latest' + if: matrix.config.os != 'windows-2022' run: | mkdir dist cp target/${{ matrix.config.target }}/release/postgrestools ./dist/postgrestools_${{ matrix.config.target }} From 625e60da4256b27865cda34172198889d3285c9f Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 4 Apr 2025 15:15:51 +0200 Subject: [PATCH 5/6] add to that --- .github/workflows/early_runners.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/early_runners.yml b/.github/workflows/early_runners.yml index 7f376d8e..a88f9189 100644 --- a/.github/workflows/early_runners.yml +++ b/.github/workflows/early_runners.yml @@ -142,3 +142,4 @@ jobs: uses: thollander/actions-comment-pull-request@v3 with: file-path: artifacts.zip + pr-number: 308 From b7c566f7e0d67e645c30b5f45b68f1dcf1f39e59 Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 4 Apr 2025 16:34:42 +0200 Subject: [PATCH 6/6] github token --- .github/workflows/early_runners.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/early_runners.yml b/.github/workflows/early_runners.yml index a88f9189..e9f47916 100644 --- a/.github/workflows/early_runners.yml +++ b/.github/workflows/early_runners.yml @@ -140,6 +140,8 @@ jobs: - name: Add PR Comment uses: thollander/actions-comment-pull-request@v3 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: file-path: artifacts.zip pr-number: 308