Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

push up some prelim tests #9

Merged
merged 11 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
45 changes: 45 additions & 0 deletions .github/workflows/pr-armed-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: ARMed Tests

on:
pull_request:

jobs:
basic-arm-test:
runs-on: macos-14
steps:
- name: Checkout action code
uses: actions/checkout@v3
- name: Run Pkg Action
uses: ./
with:
entrypoint: bin/test
upload: false
- name: Test Bin
run: |
chmod +x dist/@lando/pkg-action
dist/@lando/pkg-action --version
file dist/@lando/pkg-action | grep "Mach-O 64-bit executable arm64"

basic-cross-os-armed-tests:
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
runner:
- macos-14
- ubuntu-22.04
os:
- linux
- macos
- win

steps:
- name: Checkout action code
uses: actions/checkout@v3
- name: Run Pkg Action
uses: ./
with:
entrypoint: bin/test
arch: arm64
os: ${{ matrix.os }}
upload: false
11 changes: 6 additions & 5 deletions .github/workflows/pr-func-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:

jobs:
basic-func-test:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Checkout action code
uses: actions/checkout@v3
Expand All @@ -21,8 +21,9 @@ jobs:
fail-fast: false
matrix:
os:
- macos-11
- ubuntu-20.04
- macos-13
- macos-14
- ubuntu-22.04
- windows-2022
steps:
- name: Checkout action code
Expand All @@ -35,7 +36,7 @@ jobs:
upload: false

basic-cross-everything-test:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
Expand All @@ -51,7 +52,7 @@ jobs:
pkg:
- "[email protected]"
- "[email protected]"
- "@yao-pkg/pkg@5.10.0"
- "@yao-pkg/pkg@5.11.5"
steps:
- name: Checkout action code
uses: actions/checkout@v3
Expand Down
47 changes: 27 additions & 20 deletions .github/workflows/pr-test-inputs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:

jobs:
test-default-inputs:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Checkout action code
uses: actions/checkout@v3
Expand All @@ -29,7 +29,7 @@ jobs:
- name: "TEST: should set the correct artifact-key"
if: always()
run: |
if [ "${{ steps.default-input-tests.outputs.artifact-key }}" == "pkg-action-node16-linux-x64-${{ github.sha }}" ]; then
if [ "${{ steps.default-input-tests.outputs.artifact-key }}" == "pkg-action-node20-linux-x64-${{ github.sha }}" ]; then
echo "::notice title=TEST PASSED::Output artifact key set from defaults correctly"
else
echo "::error title=TEST FAILED!::Output artifact key not set correctly"
Expand All @@ -38,12 +38,17 @@ jobs:
shell: bash

test-arch-inputs:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
arch:
- X86
- X64
- amd64
- x64
- ARM
- ARM64
- aarch64
- arm64
steps:
Expand All @@ -60,29 +65,29 @@ jobs:
- name: "TEST: should map ${{ matrix.arch }} to x64 or arm64 as needed"
if: always()
run: |
if [ "${{ matrix.arch }}" == "x64" ]; then
if [ "${{ steps.arch-input-tests.outputs.artifact-key }}" == "pkg-action-node16-linux-x64-${{ github.sha }}" ]; then
if [ "${{ matrix.arch }}" == "X86" ] || [ "${{ matrix.arch }}" == "X64" ]; then
if [ "${{ steps.arch-input-tests.outputs.artifact-key }}" == "pkg-action-node20-linux-x64-${{ github.sha }}" ]; then
echo "::notice title=TEST PASSED::Arch mapping from ${{ matrix.arch }} to x64 correctly"
else
echo "::error title=TEST FAILED!::Arch not mapping from ${{ matrix.arch }} to x64 correctly"
exit 1
fi
elif [ "${{ matrix.arch }}" == "amd64" ]; then
if [ "${{ steps.arch-input-tests.outputs.artifact-key }}" == "pkg-action-node16-linux-x64-${{ github.sha }}" ]; then
elif [ "${{ matrix.arch }}" == "amd64" ] || [ "${{ matrix.arch }}" == "x64" ]; then
if [ "${{ steps.arch-input-tests.outputs.artifact-key }}" == "pkg-action-node20-linux-x64-${{ github.sha }}" ]; then
echo "::notice title=TEST PASSED::Arch mapping from ${{ matrix.arch }} to x64 correctly"
else
echo "::error title=TEST FAILED!::Arch not mapping from ${{ matrix.arch }} to x64 correctly"
exit 2
fi
elif [ "${{ matrix.arch }}" == "arm64" ]; then
if [ "${{ steps.arch-input-tests.outputs.artifact-key }}" == "pkg-action-node16-linux-arm64-${{ github.sha }}" ]; then
elif [ "${{ matrix.arch }}" == "ARM" ] || [ "${{ matrix.arch }}" == "ARM64" ]; then
if [ "${{ steps.arch-input-tests.outputs.artifact-key }}" == "pkg-action-node20-linux-arm64-${{ github.sha }}" ]; then
echo "::notice title=TEST PASSED::Arch mapping from ${{ matrix.arch }} to arm64 correctly"
else
echo "::error title=TEST FAILED!::Arch not mapping from ${{ matrix.arch }} to arm64 correctly"
exit 3
fi
elif [ "${{ matrix.arch }}" == "aarch64" ]; then
if [ "${{ steps.arch-input-tests.outputs.artifact-key }}" == "pkg-action-node16-linux-arm64-${{ github.sha }}" ]; then
elif [ "${{ matrix.arch }}" == "arm64" ] || [ "${{ matrix.arch }}" == "aarch64" ]; then
if [ "${{ steps.arch-input-tests.outputs.artifact-key }}" == "pkg-action-node20-linux-arm64-${{ github.sha }}" ]; then
echo "::notice title=TEST PASSED::Arch mapping from ${{ matrix.arch }} to arm64 correctly"
else
echo "::error title=TEST FAILED!::Arch not mapping from ${{ matrix.arch }} to arm64 correctly"
Expand All @@ -95,10 +100,11 @@ jobs:
test-runner-os:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- macos-11
- ubuntu-20.04
- macos-13
- ubuntu-22.04
- windows-2022

steps:
Expand All @@ -115,21 +121,21 @@ jobs:
if: always()
run: |
if [ "${{ runner.os }}" == "Linux" ]; then
if [ "${{ steps.runner-os-tests.outputs.artifact-key }}" == "pkg-action-node16-linux-x64-${{ github.sha }}" ]; then
if [ "${{ steps.runner-os-tests.outputs.artifact-key }}" == "pkg-action-node20-linux-x64-${{ github.sha }}" ]; then
echo "::notice title=TEST PASSED::Runner OS mapping to linux correctly"
else
echo "::error title=TEST FAILED!::Runner OS mapping not mapping to linux correctly"
exit 1
fi
elif [ "${{ runner.os }}" == "macOS" ]; then
if [ "${{ steps.runner-os-tests.outputs.artifact-key }}" == "pkg-action-node16-macos-x64-${{ github.sha }}" ]; then
if [ "${{ steps.runner-os-tests.outputs.artifact-key }}" == "pkg-action-node20-macos-x64-${{ github.sha }}" ]; then
echo "::notice title=TEST PASSED::Runner OS mapping to macos correctly"
else
echo "::error title=TEST FAILED!::Runner OS mapping not mapping to macos correctly"
exit 2
fi
elif [ "${{ runner.os }}" == "Windows" ]; then
if [ "${{ steps.runner-os-tests.outputs.artifact-key }}" == "pkg-action-node16-win-x64-${{ github.sha }}" ]; then
if [ "${{ steps.runner-os-tests.outputs.artifact-key }}" == "pkg-action-node20-win-x64-${{ github.sha }}" ]; then
echo "::notice title=TEST PASSED::Runner OS mapping to win correctly"
else
echo "::error title=TEST FAILED!::Runner OS mapping not mapping to win correctly"
Expand All @@ -139,8 +145,9 @@ jobs:
shell: bash

test-os-input:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
os:
- macos
Expand All @@ -162,21 +169,21 @@ jobs:
if: always()
run: |
if [ "${{ matrix.os }}" == "linux" ]; then
if [ "${{ steps.os-input-tests.outputs.artifact-key }}" == "pkg-action-node16-linux-x64-${{ github.sha }}" ]; then
if [ "${{ steps.os-input-tests.outputs.artifact-key }}" == "pkg-action-node20-linux-x64-${{ github.sha }}" ]; then
echo "::notice title=TEST PASSED::OS input ${{ matrix.os }} being used correctly"
else
echo "::error title=TEST FAILED!::OS input not being using ${{ matrix.os }} correctly"
exit 1
fi
elif [ "${{ matrix.os }}" == "macos" ]; then
if [ "${{ steps.os-input-tests.outputs.artifact-key }}" == "pkg-action-node16-macos-x64-${{ github.sha }}" ]; then
if [ "${{ steps.os-input-tests.outputs.artifact-key }}" == "pkg-action-node20-macos-x64-${{ github.sha }}" ]; then
echo "::notice title=TEST PASSED::OS input ${{ matrix.os }} being used correctly"
else
echo "::error title=TEST FAILED!::OS input not being using ${{ matrix.os }} correctly"
exit 2
fi
elif [ "${{ matrix.os }}" == "win" ]; then
if [ "${{ steps.os-input-tests.outputs.artifact-key }}" == "pkg-action-node16-win-x64-${{ github.sha }}" ]; then
if [ "${{ steps.os-input-tests.outputs.artifact-key }}" == "pkg-action-node20-win-x64-${{ github.sha }}" ]; then
echo "::notice title=TEST PASSED::OS input ${{ matrix.os }} being used correctly"
else
echo "::error title=TEST FAILED!::OS input not being using ${{ matrix.os }} correctly"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jobs:
- name: Prepare release
uses: lando/prepare-release-action@v2
with:
sync-tags: v4
sync-tags: v5
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## v5.0.0 - [March 14, 2023](https://github.com/lando/pkg-action/releases/tag/v5.0.0)

### **BREAKING CHANGES**

* Added support for `node20`
* Changed default `node` version to `node20`
* Changed default `arch` to `${{ runner.arch }}`
* Improved `arch` behavior so emulation is only used if needed
* Updated default `pkg` package to `@yao-pkg/[email protected]` since `vercel/pkg` is **DEPRECATED**

## v4.0.0 - [December 4, 2023](https://github.com/lando/pkg-action/releases/tag/v4.0.0)

### **BREAKING CHANGES**
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Pkg Action

This is a GitHub action that allows you to "compile" node projects with [pkg](https://github.com/vercel/pkg). It supports:
This is a GitHub action that allows you to "compile" node projects with [@yao-pkg/pkg](https://github.com/yao-pkg/pkg). It supports:

* All `pkg` supported node versions
* All `@yao-pkg/pkg` supported node versions
* `x64|amd64` and `aarch64|arm64`
* `macos|linux|windows`.

Expand All @@ -29,12 +29,12 @@ These keys are set to sane defaults but can be modified as needed.

| Name | Description | Default | Example |
|---|---|---|---|
| `arch` | The architecture to build for. | `amd64` | `x64` \| `amd64` \| `aarch64` \| `arm64` |
| `arch` | The architecture to build for. | `${{ runner.arch }}` | `x64` \| `amd64` \| `aarch64` \| `arm64` |
| `config` | The config file to use. | `package.json` | `config.json` |
| `node-version` | The node version to package with. | `16` | `8` \| `10` \| `12` \| `14` \| `16` |
| `node-version` | The node version to package with. | `20` | `8` \| `10` \| `12` \| `14` \| `16` \| `18` \| `20` |
| `options` | Additional options and flags to pass into pkg. | `null` | Additional [pkg options](https://github.com/vercel/pkg#usage) |
| `os` | The operating system to build for. | `${{ runner.os }}` | `linux` \| `macos` \| `win` |
| `pkg` | The `pkg` package` to use. | `pkg@5.8.1` | `latest` |
| `pkg` | The `pkg` package` to use. | `@yao-pkg/pkg@5.11.5` | `[email protected]` |
| `upload` | Upload the artifacts. Useful if you need to grab them for downstream for things like code signing. | `true` | `false` \| `true` |

## Outputs
Expand Down
50 changes: 40 additions & 10 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "Pkg Action"
description: "A GitHub Action for 'compiling' node projects into binaries using vercel/pkg."
description: "A GitHub Action for 'compiling' node projects into binaries using vercel/pkg or equivalent"
branding:
color: purple
icon: package
Expand All @@ -13,15 +13,15 @@ inputs:
arch:
description: "The architecture to build for x64|amd64|aarch64|arm64"
required: false
default: amd64
default: ${{ runner.arch }}
config:
description: "The config file to use"
required: false
default: package.json
node-version:
description: "The node version to package with"
required: false
default: 16
default: "20"
options:
description: "Additional options and flags to pass into pkg"
required: false
Expand All @@ -30,9 +30,9 @@ inputs:
required: false
default: ${{ runner.os }}
pkg:
description: "The version on @vercel/pkg to use"
description: "The version of pkg to use"
required: false
default: "pkg@5.8.1"
default: "@yao-pkg/pkg@5.11.5"
test:
description: "Hidden flag for input testing"
default: false
Expand Down Expand Up @@ -78,8 +78,28 @@ runs:
echo "target-os=${{ inputs.os }}" >> $GITHUB_OUTPUT
fi

if [ "${{ inputs.arch }}" == "amd64" ]; then
if [ "${{ runner.arch }}" == "X86" ]; then
echo "runner-arch=x64" >> $GITHUB_OUTPUT
elif [ "${{ runner.arch }}" == "X64" ]; then
echo "runner-arch=x64" >> $GITHUB_OUTPUT
elif [ "${{ runner.arch }}" == "ARM" ]; then
echo "runner-arch=arm64" >> $GITHUB_OUTPUT
elif [ "${{ runner.arch }}" == "ARM64" ]; then
echo "runner-arch=arm64" >> $GITHUB_OUTPUT
else
echo "runner-arch=${{ runner.arch }}" >> $GITHUB_OUTPUT
fi

if [ "${{ inputs.arch }}" == "X86" ]; then
echo "target-arch=x64" >> $GITHUB_OUTPUT
elif [ "${{ inputs.arch }}" == "X64" ]; then
echo "target-arch=x64" >> $GITHUB_OUTPUT
elif [ "${{ inputs.arch }}" == "amd64" ]; then
echo "target-arch=x64" >> $GITHUB_OUTPUT
elif [ "${{ inputs.arch }}" == "ARM" ]; then
echo "target-arch=arm64" >> $GITHUB_OUTPUT
elif [ "${{ inputs.arch }}" == "ARM64" ]; then
echo "target-arch=arm64" >> $GITHUB_OUTPUT
elif [ "${{ inputs.arch }}" == "aarch64" ]; then
echo "target-arch=arm64" >> $GITHUB_OUTPUT
else
Expand All @@ -89,6 +109,16 @@ runs:
echo "target-node=node${{ inputs.node-version }}" >> $GITHUB_OUTPUT
echo "::endgroup::"

- name: Validate arch emulation requirements
shell: bash
run: |
if [ "${{ steps.pkg-action-internal.outputs.target-arch }}" != "${{ steps.pkg-action-internal.outputs.runner-arch }}" ]; then
if [ "${{ runner.os }}" != "Linux" ]; then
echo "::error title=Emulation only possible on Linux!::Emulating ${{ steps.pkg-action-internal.outputs.target-arch }} is only possible on Linux runners!"
exit 48
fi
fi

- name: Install node ${{ inputs.node-version }}
uses: actions/setup-node@v3
with:
Expand Down Expand Up @@ -119,8 +149,8 @@ runs:
echo "artifact-key=${{ github.event.repository.name }}-${{ steps.pkg-action-internal.outputs.target-node }}-${{ steps.pkg-action-internal.outputs.target-os }}-${{ steps.pkg-action-internal.outputs.target-arch }}-${{ github.sha }}" >> $GITHUB_OUTPUT
echo "::endgroup::"

- name: Run x64 pkg command
if: inputs.test != 'true' && steps.pkg-action-internal.outputs.target-arch == 'x64'
- name: Run native ${{ steps.pkg-action-internal.outputs.target-arch }} pkg command
if: inputs.test != 'true' && steps.pkg-action-internal.outputs.target-arch == steps.pkg-action-internal.outputs.runner-arch
shell: bash
env:
RUNNER_DEBUG: ${{ env.RUNNER_DEBUG }}
Expand All @@ -143,8 +173,8 @@ runs:
fi
stat ${{ steps.pkg-action.outputs.file }}

- name: Run arm64 pkg command
if: inputs.test != 'true' && steps.pkg-action-internal.outputs.target-arch == 'arm64'
- name: Run emulated ${{ steps.pkg-action-internal.outputs.target-arch }} pkg command
if: inputs.test != 'true' && steps.pkg-action-internal.outputs.target-arch == 'arm64' && steps.pkg-action-internal.outputs.runner-arch == 'x64'
uses: uraimo/run-on-arch-action@v2
with:
arch: aarch64
Expand Down
Loading
Loading