php-actions / phpunit

Run PHPUnit tests in Github Actions.
106 stars 23 forks source link

Dockerfile has too many steps; eats up Github Actions time to build #22

Closed zklosko closed 3 years ago

zklosko commented 3 years ago

The dockerfile for this Github Action (IMO) has too many steps. 18 steps can easily be condensed down to 6.

FROM ghcr.io/php-actions/php-build:v1

LABEL version="1.0.0"
LABEL repository="https://github.com/php-actions/phpunit"
LABEL homepage="https://github.com/php-actions/phpunit"
LABEL maintainer="Greg Bowler <greg.bowler@g105b.com>"

RUN curl https://phar.phpunit.de/phpunit-9.phar > phpunit-9.phar
RUN curl https://phar.phpunit.de/phpunit-8.phar > phpunit-8.phar
RUN curl https://phar.phpunit.de/phpunit-7.phar > phpunit-7.phar
RUN curl https://phar.phpunit.de/phpunit-6.phar > phpunit-6.phar
RUN chmod +x *.phar
RUN ln -s $(pwd)/phpunit-9.phar /usr/local/bin/phpunit-9
RUN ln -s $(pwd)/phpunit-8.phar /usr/local/bin/phpunit-8
RUN ln -s $(pwd)/phpunit-7.phar /usr/local/bin/phpunit-7
RUN ln -s $(pwd)/phpunit-6.phar /usr/local/bin/phpunit-6
RUN ln -s /usr/local/bin/phpunit-9 /usr/local/bin/phpunit
COPY switch-phpunit-version /usr/local/bin/.
COPY entrypoint /usr/local/bin/entrypoint
ENTRYPOINT ["/usr/local/bin/entrypoint"]

can be condensed down to

FROM ghcr.io/php-actions/php-build:v1

LABEL version="1.0.0" repository="https://github.com/php-actions/phpunit" homepage="https://github.com/php-actions/phpunit" maintainer="Greg Bowler <greg.bowler@g105b.com>"

RUN curl https://phar.phpunit.de/phpunit-9.phar > phpunit-9.phar && \
  curl https://phar.phpunit.de/phpunit-8.phar > phpunit-8.phar && \
  curl https://phar.phpunit.de/phpunit-7.phar > phpunit-7.phar && \
  curl https://phar.phpunit.de/phpunit-6.phar > phpunit-6.phar && \
  chmod +x *.phar && \
  ln -s $(pwd)/phpunit-9.phar /usr/local/bin/phpunit-9 && \
  ln -s $(pwd)/phpunit-8.phar /usr/local/bin/phpunit-8 && \
  ln -s $(pwd)/phpunit-7.phar /usr/local/bin/phpunit-7 && \
  ln -s $(pwd)/phpunit-6.phar /usr/local/bin/phpunit-6 && \
  ln -s /usr/local/bin/phpunit-9 /usr/local/bin/phpunit
COPY switch-phpunit-version /usr/local/bin/.
COPY entrypoint /usr/local/bin/entrypoint
ENTRYPOINT ["/usr/local/bin/entrypoint"]
g105b commented 3 years ago

Hi, I'm currently working on bringing a new version of the action which will be extremely fast. I'm planning on finishing it today. It's already implemented for php-actions/composer and I will be moving on to this repo as soon as it's merged.

g105b commented 3 years ago

Hi @zklosko ,

Please take a look at this repository that I maintain: https://github.com/PhpGt/Database/actions/runs/428744732

I have updated the Github Actions to use the latest version of this phpunit action, and as you can see it takes 14 seconds to execute. There are still a few tasks I need to complete to wrap everything up, but it's currently a working proof of concept.

There is an issue that I've raised that I require some help on: #23 . I'm not sure how to use an array to process the arguments, and I'm hoping that someone else could take a look at it, as my bash scripting knowledge is being pushed. Is there any chance that you would be able to offer some guidance here? As soon as I can get this wrapped up I can publish the next version.

Thanks, Greg.

g105b commented 3 years ago

I'm releasing v2 of this action today. Fix is currently in master. Changes are made in master so that all docker configuration is much faster, and handled within its own repository.

Thanks for raising the issue, have a great day.