Skip to content

Migrate CI pipeline from CircleCI to GitHub Actions#103

Merged
reyang merged 15 commits intoopen-telemetry:masterfrom
Brandon-Kimberly:master
Jun 15, 2020
Merged

Migrate CI pipeline from CircleCI to GitHub Actions#103
reyang merged 15 commits intoopen-telemetry:masterfrom
Brandon-Kimberly:master

Conversation

@Brandon-Kimberly
Copy link
Copy Markdown
Contributor

@Brandon-Kimberly Brandon-Kimberly commented Jun 10, 2020

I implemented the transition of the CI pipeline in the OpenTelemetry C++ repository from CircleCI to GitHub Actions. More specifically, I have implemented a GitHub Actions workflow with separate jobs to run all tests that were previously running in CircleCI. I’m submitting this PR to add the GitHub Actions workflows for the repository. I will be submitting another PR for the integration with codecov.io (http://codecov.io/) for coverage reports to be displayed in the repository.

This is a first cut at migrating the CI pipeline from CircleCI to GitHub Actions addressing issue #102 (#102). All CircleCI jobs and tests have been ported over to Actions. Note: I have left the CircleCI config file in the repository for now.

Update

All jobs are running correctly now and this PR, unless anybody has more feedback, should be good to go!

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla bot commented Jun 10, 2020

CLA Check
The committers are authorized under a signed CLA.

@pyohannes
Copy link
Copy Markdown
Contributor

Could you please rebase? It seems this contains lots of unrelated changes.

@Brandon-Kimberly
Copy link
Copy Markdown
Contributor Author

Could you please rebase? It seems this contains lots of unrelated changes.

I'm sorry. Could you please elaborate on how I would do that? I tried to rebase before submitting but I guess I messed it up somehow.

@pyohannes
Copy link
Copy Markdown
Contributor

Could you please elaborate on how I would do that?

You could do a hard reset of your branch to origin/master, then cherry-pick all the commits that you have made and do a force-push.

If you don't mind losing commit history, you can reset your branch to origin/master, copy in your modifications, commit and force-push.

Copy link
Copy Markdown

@anuraaga anuraaga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice README updates :) Left some small comments on the ci config

@meastp
Copy link
Copy Markdown
Contributor

meastp commented Jun 11, 2020

@Brandon-Kimberly I'm looking at the windows failures... When I scroll through the output in CI / windows I can only see output for ./ci/setup_windows_cmake.ps1 and not ./ci/setup_windows_ci_environment.ps1 or ./ci/install_windows_protobuf.ps1 which should have some output if it did run.

Perhaps you could format the workflow file run commands on multiple lines to make it easier to read?

Also, perhaps there is a difference between the windows shell and ubuntu shell wrt to space-separated scripts on a single line?

Try this:

  windows:

    runs-on: windows-2019

    steps:
    - uses: actions/checkout@v2
    - name: setup
      run: |
        ./ci/setup_windows_cmake.ps1
        ./ci/setup_windows_ci_environment.ps1
        ./ci/install_windows_protobuf.ps1
      timeout-minutes: 15
    - name: run cmake test
      run: ./ci/do_ci.ps1 cmake.test
    - name: run otprotocol test
      run: ./ci/do_ci.sh cmake.exporter.otprotocol.test

Also removed the whitespace lines within the jobs.
This fixes an issue with the Windows jobs not running multiple executables in the same line.
Was mistakenly executing bazel.build test when it should be running the format tool.
@Brandon-Kimberly
Copy link
Copy Markdown
Contributor Author

@Brandon-Kimberly What happened? I think this is a great feature - why did you close it and delete the commits (by force push)?

I accidentally messed up the rebasing. Fixing now.

@Brandon-Kimberly
Copy link
Copy Markdown
Contributor Author

@Brandon-Kimberly I'm looking at the windows failures... When I scroll through the output in CI / windows I can only see output for ./ci/setup_windows_cmake.ps1 and not ./ci/setup_windows_ci_environment.ps1 or ./ci/install_windows_protobuf.ps1 which should have some output if it did run.

Perhaps you could format the workflow file run commands on multiple lines to make it easier to read?

Also, perhaps there is a difference between the windows shell and ubuntu shell wrt to space-separated scripts on a single line?

Try this:

  windows:

    runs-on: windows-2019

    steps:
    - uses: actions/checkout@v2
    - name: setup
      run: |
        ./ci/setup_windows_cmake.ps1
        ./ci/setup_windows_ci_environment.ps1
        ./ci/install_windows_protobuf.ps1
      timeout-minutes: 15
    - name: run cmake test
      run: ./ci/do_ci.ps1 cmake.test
    - name: run otprotocol test
      run: ./ci/do_ci.sh cmake.exporter.otprotocol.test

Wow you're right! Windows does only allow one executable per line. The others are ignored.

Putting the different run commands on separate lines fixed one of the Windows jobs. Unfortunately one still fails stating that "The term './ci/install_windows_protobuf.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program."

@meastp
Copy link
Copy Markdown
Contributor

meastp commented Jun 11, 2020

@Brandon-Kimberly I'm looking at the windows failures... When I scroll through the output in CI / windows I can only see output for ./ci/setup_windows_cmake.ps1 and not ./ci/setup_windows_ci_environment.ps1 or ./ci/install_windows_protobuf.ps1 which should have some output if it did run.
Perhaps you could format the workflow file run commands on multiple lines to make it easier to read?
Also, perhaps there is a difference between the windows shell and ubuntu shell wrt to space-separated scripts on a single line?
Try this:

  windows:

    runs-on: windows-2019

    steps:
    - uses: actions/checkout@v2
    - name: setup
      run: |
        ./ci/setup_windows_cmake.ps1
        ./ci/setup_windows_ci_environment.ps1
        ./ci/install_windows_protobuf.ps1
      timeout-minutes: 15
    - name: run cmake test
      run: ./ci/do_ci.ps1 cmake.test
    - name: run otprotocol test
      run: ./ci/do_ci.sh cmake.exporter.otprotocol.test

Wow you're right! Windows does only allow one executable per line. The others are ignored.

Putting the different run commands on separate lines fixed one of the Windows jobs. Unfortunately one still fails stating that "The term './ci/install_windows_protobuf.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program."

Great! Perhaps you need to explicitly state that you want powershell as the shell? EDIT: Nevermind (https://github.blog/changelog/2019-10-17-github-actions-default-shell-on-windows-runners-is-changing-to-powershell/)

EDIT2: It seems that shell: powershell (which is the default and therefore does not have to be explicitly used) and shell: pwsh (powershell core) are two different shells. You could also try the latter.

You can also try to use a Windows-y slash in the paths: e.g. ./ci/install_windows_protobuf.ps1 -> .\ci\install_windows_protobuf.ps1, although powershell is supposed to accept both / and \

@Brandon-Kimberly You could also split the three commands (or the last command, which is the one failing) into a separate run: task... Then work on unifying them into a single run-command after the PR is merged? :)

@Brandon-Kimberly
Copy link
Copy Markdown
Contributor Author

Update: After trying the suggestions above, one of the Windows jobs now passes correctly!

However, the Windows OTProtocol test still fails on account of not being able to locate the file "\ci\install_windows_protobuf.ps1". I have tried to fix this by using '' instead of '/' and by specifying that the job uses powershell core. But the test is still failing. If anybody has any suggestions I would be very thankful!

Additionally, the format job always fails as well. The job runs the format tool correctly and says that some files do not abide by the formatting specifications. Running the format tool on my local machine changes a few files including ci/setup_windows_cmake.ps1, tools/git-cl.cmd, and tools/setup-devenv.cm. However, when trying to push those files to the remote repository I am met with this warning:

"warning: LF will be replaced by CRLF in tools/setup-devenv.cmd.
The file will have its original line endings in your working directory"

Again, I welcome any help on this issue.

@Brandon-Kimberly Brandon-Kimberly changed the title Migrate CI pipeline from CircleCI to GitHub Actions [WIP] Migrate CI pipeline from CircleCI to GitHub Actions Jun 11, 2020
@meastp
Copy link
Copy Markdown
Contributor

meastp commented Jun 11, 2020

@Brandon-Kimberly I finally found the issue on Windows: it is simply the ci/setup_windows_ci_environment.ps1 script that changes directory to vcpkg.

To fix this, change ci/setup_windows_ci_environment.ps1 from:

(remove cd vcpkg)

trap { $host.SetShouldExit(1) }

git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
$VCPKG_DIR=(Get-Item -Path ".\").FullName
./bootstrap-vcpkg.bat
./vcpkg integrate install
./vcpkg install benchmark:x64-windows
./vcpkg install gtest:x64-windows

to:

(add Push-Location and Pop-Location)

trap { $host.SetShouldExit(1) }

git clone https://github.com/Microsoft/vcpkg.git
Push-Location -Path vcpkg
$VCPKG_DIR=(Get-Item -Path ".\").FullName
./bootstrap-vcpkg.bat
./vcpkg integrate install
./vcpkg install benchmark:x64-windows
./vcpkg install gtest:x64-windows
Pop-Location

I think it is more consistent to use / in paths (in the github actions workflow file) on Windows as well as this was not the issue. Do what you please :)

@meastp
Copy link
Copy Markdown
Contributor

meastp commented Jun 11, 2020

@Brandon-Kimberly ok, I think I figured out the format issue as well

  • As far as I can tell, the tools/format.sh script removes carriage return (CR) from all files. This is problematic for .cmd and .ps1 files in the ci directory, which according to the .gitattributes file should have crlf line endings.

(this is also why git commands give warnings as the one you saw)

  • to fix this, I propose changing ./ci/do_ci.sh to running git add --renormalize . after tools/format.sh and before git ls-files --modified to normalise line endings according to .gitattributes.

from:

elif [[ "$1" == "format" ]]; then
  tools/format.sh
  CHANGED="$(git ls-files --modified)"

to:

elif [[ "$1" == "format" ]]; then
  tools/format.sh
  # normalize file endings according to .gitattributes
  git add --renormalize .
  CHANGED="$(git ls-files --modified)"

This fixes the Windows job from always failing.
Was split up earlier due to one of the jobs always resulting in a failure.
@Brandon-Kimberly
Copy link
Copy Markdown
Contributor Author

@Brandon-Kimberly ok, I think I figured out the format issue as well

* As far as I can tell, the `tools/format.sh` script removes carriage return (CR) from all files. This is problematic for .cmd and .ps1 files in the ci directory, which according to the .gitattributes file should have crlf line endings.

(this is also why git commands give warnings as the one you saw)

* to fix this, I propose changing `./ci/do_ci.sh` to running `git add --renormalize .` after `tools/format.sh` and before `git ls-files --modified` to normalise line endings according to .gitattributes.

from:

elif [[ "$1" == "format" ]]; then
  tools/format.sh
  CHANGED="$(git ls-files --modified)"

to:

elif [[ "$1" == "format" ]]; then
  tools/format.sh
  # normalize file endings according to .gitattributes
  git add --renormalize .
  CHANGED="$(git ls-files --modified)"

Thanks this worked! I figured it had something to do with line endings but was unsure how to modify the format job to account for this.

@Brandon-Kimberly
Copy link
Copy Markdown
Contributor Author

@Brandon-Kimberly I finally found the issue on Windows: it is simply the ci/setup_windows_ci_environment.ps1 script that changes directory to vcpkg.

To fix this, change ci/setup_windows_ci_environment.ps1 from:

(remove cd vcpkg)

trap { $host.SetShouldExit(1) }

git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
$VCPKG_DIR=(Get-Item -Path ".\").FullName
./bootstrap-vcpkg.bat
./vcpkg integrate install
./vcpkg install benchmark:x64-windows
./vcpkg install gtest:x64-windows

to:

(add Push-Location and Pop-Location)

trap { $host.SetShouldExit(1) }

git clone https://github.com/Microsoft/vcpkg.git
Push-Location -Path vcpkg
$VCPKG_DIR=(Get-Item -Path ".\").FullName
./bootstrap-vcpkg.bat
./vcpkg integrate install
./vcpkg install benchmark:x64-windows
./vcpkg install gtest:x64-windows
Pop-Location

I think it is more consistent to use / in paths (in the github actions workflow file) on Windows as well as this was not the issue. Do what you please :)

Thank you, this worked as well! I guess the problem was that the job ended up running in a different directory then I thought.

Thank you for all your help! 😄

@Brandon-Kimberly Brandon-Kimberly changed the title [WIP] Migrate CI pipeline from CircleCI to GitHub Actions Migrate CI pipeline from CircleCI to GitHub Actions Jun 12, 2020
@Brandon-Kimberly Brandon-Kimberly requested a review from g-easy June 12, 2020 14:49
Copy link
Copy Markdown
Contributor

@pyohannes pyohannes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that looks really great!

Copy link
Copy Markdown
Member

@reyang reyang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me! 🥇

...again. Some jobs were still not displaying the full name on the GitHub Actions UI.
Copy link
Copy Markdown
Contributor

@pyohannes pyohannes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, I think it's ready to go. I have one small nit that's not critical (yet).

Was previously set to run on Ubuntu latest but Ubuntu 20.04 does not support GCC 48.
@Brandon-Kimberly
Copy link
Copy Markdown
Contributor Author

Branch is rebased and should be good to go!

@Brandon-Kimberly Brandon-Kimberly requested a review from reyang June 15, 2020 14:05
Copy link
Copy Markdown
Member

@reyang reyang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@reyang reyang merged commit 422b7a4 into open-telemetry:master Jun 15, 2020
@g-easy
Copy link
Copy Markdown
Contributor

g-easy commented Jul 28, 2020

Oops, git add --renormalize broke format CI. We haven't been enforcing formatting since.

@g-easy
Copy link
Copy Markdown
Contributor

g-easy commented Jul 28, 2020

Fix in #222

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants