https://github.com/marketplace/actions/cross-platform-action Skip to content Toggle navigation Sign up * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code + Explore + All features + Documentation + GitHub Skills + Blog * Solutions + For + Enterprise + Teams + Startups + Education + By Solution + CI/CD & Automation + DevOps + DevSecOps + Case Studies + Customer Stories + Resources * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles + Repositories + Topics + Trending + Collections * Pricing [ ] * # Search All GitHub | Jump to | * No suggested jump to results * # Search All GitHub | Jump to | * # Search All GitHub | Jump to | * # Search All GitHub | Jump to | Sign in Sign up {{ message }} 1. Marketplace 2. Actions 3. Cross Platform Action GitHub Action Cross Platform Action v0.9.0 Latest version Use latest version Cross Platform Action Provides cross platform runner Installation Copy and paste the following snippet into your .yml file. - name: Cross Platform Action uses: cross-platform-actions/action@v0.9.0 Learn more about this action in cross-platform-actions/action Choose a version v0.9.0 Cross Platform Action 0.9.0 v0.8.0 Cross Platform Action 0.8.0 v0.7.0 Cross Platform Action 0.7.0 v0.6.2 Cross Platform Action 0.6.2 v0.6.1 Cross Platform Action 0.6.1 v0.6.0 Cross Platform Action 0.6.0 v0.5.0 Cross Platform Action 0.5.0 v0.4.0 Cross Platform Action 0.4.0 v0.3.1 Cross Platform Action 0.3.1 v0.3.0 Cross Platform Action 0.3.0 Cross-Platform GitHub Action This project provides a GitHub action for running GitHub Action workflows on multiple platforms. This includes platforms that GitHub Actions doesn't currently natively support. Features Some of the features that are supported include: * Multiple operating system with one single action * Multiple versions of each operating system * Allows to use default shell or Bash shell * Low boot overhead * Fast execution Usage Here's a sample workflow file which will setup a matrix resulting in four jobs. One which will run on FreeBSD 13.1, one which runs OpenBSD 7.2, one which runs NetBSD 9.2 and one which runs OpenBSD 7.2 on ARM64. name: CI on: [push] jobs: test: runs-on: ${{ matrix.os.host }} strategy: matrix: os: - name: freebsd architecture: x86-64 version: '13.1' host: macos-12 - name: openbsd architecture: x86-64 version: '7.2' host: macos-12 - name: openbsd architecture: arm64 version: '7.2' host: ubuntu-latest - name: netbsd architecture: x86-64 version: '9.2' host: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Test on ${{ matrix.os.name }} uses: cross-platform-actions/action@v0.9.0 env: MY_ENV1: MY_ENV1 MY_ENV2: MY_ENV2 with: environment_variables: MY_ENV1 MY_ENV2 operating_system: ${{ matrix.os.name }} architecture: ${{ matrix.os.architecture }} version: ${{ matrix.os.version }} shell: bash run: | uname -a echo $SHELL pwd ls -lah whoami env | sort Different platforms need to run on different runners, see the Runners section below. Inputs This section lists the available inputs for the action. Input Required Default Description Value Runs command-line programs run using the operating system's shell. This will be executed inside the virtual machine. The type of operating system operating_system to run the job on. See Supported Platforms. The version of the operating version system to use. See Supported Platforms. The shell to use to execute the commands. Defaults to the shell default default shell for the given operating system. Allowed values are: default, sh and bash A list of environment variables to forward to the environment_variables "" virtual machine. The list should be separated with spaces. All inputs are expected to be strings. It's important that especially the version is explicitly specified as a string, using single or double quotes. Otherwise YAML might interpet the value as a numeric value instead of a string. This might lead to some unexpected behavior. If the version is specified as version: 13.0, YAML will interpet 13.0 as a floating point number, drop the fraction part (because 13 and 13.0 are the same) and the GitHub action will only see 13 instead of 13.0. The solution is to explicitly state that a string is required by using quotes: version: '13.0'. Supported Platforms This sections lists the currently supported platforms by operating system. Each operating system will list which versions are supported. OpenBSD (openbsd) Version x86-64 arm64 7.2 7.1 6.9 6.8 FreeBSD (freebsd) Version x86-64 13.1 13.0 12.4 12.2 NetBSD (netbsd) Version x86-64 9.2 Runners This section list the different combinations of platforms and on which runners they can run. Runner OpenBSD FreeBSD NetBSD Linux macos-10.15, macos-11, macos-12 Under the Hood GitHub Actions currently only support the following platforms: macOS, Linux and Windows. To be able to run other platforms, this GitHub action runs the commands inside a virtual machine (VM). If the host platform is macOS the hypervisor can take advantage of nested virtualization. The FreeBSD and OpenBSD VMs run on the xhyve hypervisor (on a macOS host), while the other platforms run on the QEMU hypervisor (on a Linux host). xhyve is built on top of Apple's Hypervisor framework. The Hypervisor framework allows to implement hypervisors with support for hardware acceleration without the need for kernel extensions. xhyve is a lightweight hypervisor that boots the guest operating systems quickly and requires no dependencies outside of what's provided by the system. QEMU is a more general purpose hypervisor that runs on most host platforms and supports most guest systems. It's a bit slower than xhyve because it's general purpose and it cannot use nested virtualization on the Linux hosts provided by GitHub. The VM images running inside the hypervisor are built using Packer. It's a tool for automatically creating VM images, installing the guest operating system and doing any final provisioning. The GitHub action uses SSH to communicate and execute commands inside the VM. It uses rsync to share files between the guest VM and the host. xhyve does not have any native support for sharing files. To authenticate the SSH connection a unique key pair is used. This pair is generated each time the action is run. The public key is added to the VM image and the private key is stored on the host. Since xhyve does not support file sharing, a secondar hard drive, which is backed by a file, is created. The public key is stored on this hard drive, which is then mounted by the VM. At boot time, the secondary hard drive will be identified and the public key will be copied to the appropriate location. To reduce the time it takes for the GitHub action to start executing the commands specified by the user, it aims to boot the guest operating systems as fast as possible. This is achieved in a couple of ways: * By downloading resources, like the hypervisor and a few other tools, instead of installing them through a package manager * No compression is used for the resources that are downloaded. The size is small enough anyway and it's faster to download the uncompressed data than it is to download compressed data and then uncompress it. * It leverages async/await to perform tasks asynchronously. Like downloading the VM image and other resources at the same time * It performs as much as possible of the setup ahead of time when the VM image is provisioned Local Development Prerequisites * NodeJS * npm * git Instructions 1. Install the above prerequisites 2. Clone the repository by running: git clone https://github.com/cross-platform-actions/action 3. Navigate to the newly cloned repository: cd action 4. Install the dependencies by running: npm install 5. Run any of the below npm commands npm Commands The following npm commands are available: * build - Build the GitHub action * format - Reformat the code * lint - Lint the code * package - Package the GitHub action for distribution and end to end testing * test - Run unit tests * all - Will run all of the above commands Running End to End Tests The end to end tests can be run locally by running it through Act. By default, resources and VM images will be downloaded from github.com. By running a local HTTP server it's possible to point the GitHub action to local resources. Prerequisites * Docker * Act Instructions 1. Install the above prerequisites 2. Copy test/workflows/ci.yml.example to test/workflows/ci.yml 3. Make any changes you like to test/workflows/ci.yml, this is file ignored by Git 4. Build the GitHub action by running: npm run build 5. Package the GitHub action by running: npm run package 6. Run the GitHub action by running: act --privileged -W test/ workflows Providing Resources Locally The GitHub action includes a development dependency on a HTTP server. The test/http directory contains a skeleton of a directory structure which matches the URLs that the GitHub action uses to download resources. All files within the test/http are ignore by Git. 1. Add resources as necessary to the test/http directory 2. In one shell, run the following command to start the HTTP server: ./node_modules/http-server/bin/http-server test/http -a 127.0.0.1 The -a flag configures the HTTP server to only listen for incoming connections from localhost, no external computers will be able to connect. 3. In another shell, run the GitHub action by running: act --privileged -W test/workflows --env CPA_RESOURCE_URL= Where is the URL inside Docker that points to localhost of the host machine, for macOS, this is http:// host.docker.internal:8080. By default, the HTTP server is listening on port 8080. Stars Star 37 Contributors @jacob-carlborg @adamsmd Categories Continuous integration Testing Links cross-platform-actions/action Open issues 1 Pull requests 1 Report abuse Cross Platform Action is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation. Product * Features * Security * Team * Enterprise * Customer stories * The ReadME Project * Pricing * Resources * Roadmap Platform * Developer API * Partners * Electron * GitHub Desktop Support * Docs * Community Forum * Professional Services * Skills * Status * Contact GitHub Company * About * Blog * Careers * Press * Inclusion * Social Impact * Shop * Twitter icon GitHub on Twitter * Facebook icon GitHub on Facebook * Linkedin icon GitHub on LinkedIn * YouTube icon GitHub on YouTube * Twitch icon GitHub on Twitch * TikTok icon GitHub on TikTok * GitHub mark GitHub's organization on GitHub * (c) 2023 GitHub, Inc. * Terms * Privacy (Updated 08/2022) * Site Map * What is Git? You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.