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

Make action work on all OS #19

Closed
joshrlesch opened this issue Sep 16, 2020 · 24 comments
Closed

Make action work on all OS #19

joshrlesch opened this issue Sep 16, 2020 · 24 comments
Labels
enhancement New feature or request

Comments

@joshrlesch
Copy link

This action is only supported on Linux since its container based. Is it possible to support multiple OS for use with self-hosted runners like internal Macs.

@EnricoMi
Copy link
Owner

EnricoMi commented Sep 17, 2020

That is a good question. So I think the only alternative to a container action would be the Composite run steps. That should work on Linux, MacOS, Windows. Do you agree?

I presume you can mix operating systems and self-hosted with GitHub-hosted jobs in the same workflow. For the time being, you could then run your tests on your self-hosted MacOS runners and upload the test result files as artifacts. In a separate job in the same workflow you can then publish the unit test results using a GitHub-hosted Linux based job:

jobs:
  test:
    runs-on: [self-hosted, macOs]
  ...
    - name: Upload Unit Test Results
      if: always()
      uses: actions/upload-artifact@v2
      with:
        name: Unit Test Results
        path: **/*.xml

  publish-test-results:
    name: "Publish Unit Tests Results"
    needs: test
    runs-on: ubuntu-latest
    if: always()

    steps:
      - name: Download Artifacts
        uses: actions/download-artifact@v2
        with:
          path: artifacts

      - name: Publish Unit Test Results
        uses: EnricoMi/publish-unit-test-result-action@master
        with:
          check_name: Unit Test Results
          github_token: ${{ secrets.GITHUB_TOKEN }}
          files: "artifacts/**/*.xml"

Is that an option for you?

@EnricoMi EnricoMi added the enhancement New feature or request label Sep 17, 2020
@joshrlesch
Copy link
Author

Thanks for the reply! I think that is a decent alternative for the time being. Since you marked this with a enhancement label, do you think it's possible to add support for multi OS's? I know there is a limitation by GH for this to work out of the box, but if there is a change that would be great!

@EnricoMi
Copy link
Owner

I'll try the 'composite run steps' action. I don't see why this shouldn't work. And you are right, having this run on multiple OS would be great.

@EnricoMi EnricoMi changed the title Container action is only supported on Linux Make action work on all OS Sep 17, 2020
@EnricoMi
Copy link
Owner

Hi,

I have turned this action into a "composite run steps action".

Please give it a try:

uses: EnricoMi/publish-unit-test-result-action@branch-composite-action

You need to add a python step before this action:

- name: Setup Python
  uses: actions/setup-python@v2
  with:
    python-version: 3

@EnricoMi
Copy link
Owner

@joshrlesch have you had a chance to try the "composite run steps action" on MacOS?

@joshrlesch
Copy link
Author

@joshrlesch have you had a chance to try the "composite run steps action" on MacOS?

I kinda have. I tried it quick, but ran into python environment errors on our Macs. I wasn't able to look into it much further, but still plan on getting to this sometime.

@EnricoMi
Copy link
Owner

Do you run this on a public github? Then I could look into the action's output.

@joshrlesch
Copy link
Author

Do you run this on a public github? Then I could look into the action's output.

Nope, this is a private company repo. Hopefully I can get to this later this week.

@EnricoMi
Copy link
Owner

Alright. Did you see that you need to add a Python step before this action now? See https://github.com/EnricoMi/publish-unit-test-result-action/tree/branch-composite-action#using-this-action.

@jonathanmedd
Copy link

I'd be interested in running this on windows-latest. I tried the above with:

- name: Setup Python
  uses: actions/setup-python@v2
  with:
    python-version: 3

- name: Publish Unit Test Results
  uses: EnricoMi/publish-unit-test-result-action@branch-composite-action
  if: always()
  with:
    github_token: ${{ secrets.GITHUB_TOKEN }}
    files: tools\testResults.xml

but got the following error:

Install Python dependencies
  Collecting pip
    Downloading pip-21.0.1-py3-none-any.whl (1.5 MB)
  Installing collected packages: pip
    Attempting uninstall: pip
      Found existing installation: pip 21.0.1
      Uninstalling pip-21.0.1:
        Successfully uninstalled pip-21.0.1
  Successfully installed pip-21.0.1
  Collecting virtualenv
    Downloading virtualenv-20.4.2-py2.py3-none-any.whl (7.2 MB)
  Collecting distlib<1,>=0.3.1
    Downloading distlib-0.3.1-py2.py3-none-any.whl (335 kB)
  Collecting filelock<4,>=3.0.0
    Downloading filelock-3.0.12-py3-none-any.whl (7.6 kB)
  Collecting appdirs<2,>=1.4.3
    Downloading appdirs-1.4.4-py2.py3-none-any.whl (9.6 kB)
  Collecting six<2,>=1.9.0
    Downloading six-1.15.0-py2.py3-none-any.whl (10 kB)
  Installing collected packages: six, filelock, distlib, appdirs, virtualenv
  Successfully installed appdirs-1.4.4 distlib-0.3.1 filelock-3.0.12 six-1.15.0 virtualenv-20.4.2
  created virtual environment CPython3.9.1.final.0-64 in 3255ms
    creator CPython3Windows(dest=D:\a\BricksetModule\BricksetModule\venv, clear=False, no_vcs_ignore=False, global=False)
    seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=C:\Users\runneradmin\AppData\Local\pypa\virtualenv)
      added seed packages: pip==21.0.1, setuptools==52.0.0, wheel==0.36.2
    activators BashActivator,BatchActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
  D:\a\_temp\9385afb1-1783-4090-9189-59028d9e99d9.sh: line 5: venv/bin/activate: No such file or directory
  Error: Process completed with exit code 1.

Were you expecting it to work on windows-latest yet?

@EnricoMi
Copy link
Owner

EnricoMi commented Feb 16, 2021

You can test the action from this branch:

uses: EnricoMi/publish-unit-test-result-action@branch-composite-action-win

Be reminded this is just a development branch.

@EnricoMi
Copy link
Owner

EnricoMi commented Feb 16, 2021

@joshrlesch I have tested the composite action on Mac OS X (10.15.7) and it works.

@jonathanmedd
Copy link

@EnricoMi Tested fine for me on windows-latest

@wildmichael
Copy link

@EnricoMi The composite-action-win branch works fine on windows-latest, but currently fails on ubuntu-latest. The branch composite-action shows the exact opposite behavior. Any chance of getting both to work?

@EnricoMi
Copy link
Owner

@joshrlesch @jonathanmedd @wildmichael This action is not available as a composite action from master branch. Please give it a try:

- name: Publish Unit Test Results
  uses: EnricoMi/publish-unit-test-result-action/composite@master
  if: always()
  with:
    files: test-results/**/*.xml

Note that master is a development branch and may break any time, so do not use in production.

This will be released soon and will be available via @v1 then.

@jonathanmedd
Copy link

@EnricoMi Tried it on windows-latest, get this issue:

Publish Unit Test Results
  Traceback (most recent call last):
    File "D:\a\_actions\EnricoMi\publish-unit-test-result-action\master\composite/../publish_unit_test_results.py", line 201, in <module>
      main(settings)
    File "D:\a\_actions\EnricoMi\publish-unit-test-result-action\master\composite/../publish_unit_test_results.py", line 52, in main
      files = [str(file) for file in pathlib.Path().glob(settings.files_glob)]
    File "D:\a\_actions\EnricoMi\publish-unit-test-result-action\master\composite/../publish_unit_test_results.py", line 52, in <listcomp>
      files = [str(file) for file in pathlib.Path().glob(settings.files_glob)]
    File "C:\hostedtoolcache\windows\Python\3.7.9\x64\lib\pathlib.py", line 1123, in glob
      raise NotImplementedError("Non-relative patterns are unsupported")
  NotImplementedError: Non-relative patterns are unsupported
  Error: Process completed with exit code 1.

You can see the full action run here if it helps: https://github.com/jonathanmedd/BricksetModule/runs/2323106971?check_suite_focus=true

@EnricoMi
Copy link
Owner

@jonathanmedd thanks for testing this. Looks like your files: "${{ github.workspace }}/tools/testResults.xml" pattern is problematic. Can you try:

  • files: "${{ github.workspace }}\\tools\\testResults.xml"
  • files: "tools/testResults.xml"

@jonathanmedd
Copy link

Tried both:

  • files: "${{ github.workspace }}\\tools\\testResults.xml" 👎
  • files: "tools/testResults.xml" 👍

So all is now good, thanks!

@EnricoMi
Copy link
Owner

Looks like Python prefers forward slashes on all OS and can translate it as required. Nice! This proves my README right :-)

Thanks for confirming it works for you.

@WimLeflere
Copy link

Nice work adding Windows and Mac support.

I was using composite@v1 from the README which doesn't work yet, as not yet released on v1.
Switched to master for now.

@EnricoMi
Copy link
Owner

@WimLeflere thanks for testing!

@EnricoMi
Copy link
Owner

This has been released, so it is available now as documented in the README.md via

uses: EnricoMi/publish-unit-test-result-action/composite@v1

Thanks for the patience.

@jozza3000
Copy link

running on a windows selfhosted machine, getting this error:-

Run EnricoMi/publish-unit-test-result-action/composite@v1
o '##[group]Check for Python3'
echo '##[group]Check for Python3'
shell: C:\WINDOWS\system32\bash.EXE --noprofile --norc -e -o pipefail {0}
env:
JAVA_HOME: C:\actions-runner_work_tool\Java_Temurin-Hotspot_jdk\16.0.2-7\x64

/bin/bash: C:actions-runner_work_temp816f90e7-306e-4145-a6a6-e890e998056b.sh: No such file or directory
Error: Process completed with exit code 1.

@EnricoMi
Copy link
Owner

@jozza3000 Please see #211.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants