ddev / github-action-setup-ddev

Set up your GitHub Actions workflow with DDEV
GNU General Public License v3.0
35 stars 7 forks source link

Support nektos/act for local GitHub actions testing #22

Open justafish opened 1 year ago

justafish commented 1 year ago

The Issue

Running DDEV with act is not currently possible

ddev config global --instrumentation-opt-in=false --omit-containers=ddev-ssh-agent
Could not connect to a Docker provider. Please start or install a Docker provider.

How This PR Solves The Issue

See https://github.com/nektos/act/issues/724

Manual Testing Instructions

Create a new workflow with this action:

name: "Test Local Install"

on:
  push:
    branches:
      - master
  pull_request:
    types: [opened, synchronize, reopened]

concurrency:
  group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
  cancel-in-progress: true

jobs:
  Test-Local-Install:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: ./.github/actions/github-action-setup-ddev

Run act:

act -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:runner-latest pull_request

Automated Testing Overview

Modification for locals

Related Issue Link(s)

Release/Deployment Notes

rfay commented 1 year ago

I have never gotten act to work for anything! Glad this can make it work here.

tyler36 commented 12 months ago

Is there a way I can test this?

rfay commented 12 months ago

I think you should be able to do it by installing and using https://github.com/nektos/act

tyler36 commented 8 months ago

Any progress here?

freshworkx commented 7 months ago

Why has this PR not yet found its way into the main branch? Is there anything against it? If not, please merge.

rfay commented 7 months ago

It hasn't gotten a review from anybody. Nobody has reported manually testing it with success.

I rebased it.

Please experiment with it and review it. It can be found at https://github.com/justafish/github-action-setup-ddev/tree/justafish/support-nektos-act

freshworkx commented 7 months ago

@rfay First of all, you should add a note to the documentation that you have to use the image with runner as user: act -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:runner-latest

But unfortunately this does not work in my environment with Win11/WSL2 (Docker is installed inside WSL). When the command sudo chown runner:docker /var/run/docker.sock is running, the Docker instance on the host (wsl) crashes completely. I have to restart the entire wsl2 environment to be able to work again. I actually assumed that this command would only be executed within the ACT container. It looks like this is not working with my local user/group.

rfay commented 7 months ago

@freshworkx If I understand what you're saying you tested this PR and couldn't get it to work.

My own experience is that I've never gotten nektos/act to work for anything I've wanted it to work for, but @justafish must be succeeding...

freshworkx commented 7 months ago

@rfay Thanks for your reply. To be clear, ACT itself works in my local environment. It is only in combination with the DDEV GitHub action that an error occurs. Maybe @justafish can report in which environment / installation she was able to test this successfully.

justafish commented 7 months ago

she has tested it on Linux and Mac M1

freshworkx commented 6 months ago

I did a little testing over the weekend. The solution from @penyaskito https://github.com/nektos/act/issues/1798#issuecomment-2030908166 seems to work without modifying the main.js. This solves the problem with the sudo chown command. However, there are other problems, such as with a PHP matrix. At the latest when starting up the 2nd PHP version there is an error: Failed to start xxx: unable to listen on required ports, port 443 is already in use. The whole thing looks like not very sophisticated yet and I'm wondering whether this combination of act and ddev really makes sense, or whether you should continue to use composer scripts in the pipeline.

jonaseberle commented 6 months ago

Sorry I haven't noticed this PR.

But if I understand that correctly, we do not need this PR anymore and the solution for docker-in-docker is instead a different act configuration?

Although I have worked a lot with Github actions I have not used act yet. It seems to have a lot of traction currently. But mind that you can always just copy this workflow into your project or fork it.