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

Add several syntactical, functional and logic improvements (#11) #595

Open
wants to merge 6 commits into
base: vnext
Choose a base branch
from

Conversation

aleks-ivanov
Copy link
Contributor

@aleks-ivanov aleks-ivanov commented May 20, 2021

You will see that the pipeline fails at the "Run unit tests" step and here is why.

We discovered that on ubuntu-latest (Ubuntu 20.04), one of the tests from the Microsoft.OpenApi.Tests project fails. The test is called Microsoft.OpenApi.Tests.OpenApiWorkspaceTests.OpenApiWorkspacesShouldNormalizeDocumentLocations.

The same test completes successful on Windows 10 and windows-latest (Windows Server 2019).

Now to make it even more interesting, in the previous iteration of the pipeline you can see in the logs that the test fails, but for some odd reason, there is no exit code and therefor the pipeline doesn't fail.

In the one this PR is for, the same test again fails BUT now the pipeline also fails as it should.

In case this fail is a false positive, we've tested the pipeline on windows-latest and everything runs smoothly, since the test in question does not fail, so we can switch the runner of the CI job from ubuntu-latest to windows-latest.

Other than that, check out in a bit the comments on each change for info on the optimizations.

Resolves #594

* add several improvements and simplifications

* add a few script improvements

* add tests logger and upload results as artifact

* add path to source project files search in build step

* add path to project files search in test step
@@ -46,7 +56,7 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0

- if: steps.conditionals_handler.outputs.is_default_branch == 'true'
- if: steps.conditionals_handler.outputs.is_push_to_default_branch == 'true'
Copy link
Contributor Author

@aleks-ivanov aleks-ivanov May 20, 2021

Choose a reason for hiding this comment

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

Used the newly added is_push_to_default_branch condition, instead of the is_default_branch, to further restrict the new tag generating step to only execute when a push commit to the default branch is made.

Copy link
Member

Choose a reason for hiding this comment

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

I'm somewhat confused by this process. First, the default branch is vnext, not master. We don't create releases when we are updating vnext. Also, we don't push directly to vnext, we generally PR to it. What am I missing?

Copy link
Contributor Author

@aleks-ivanov aleks-ivanov May 24, 2021

Choose a reason for hiding this comment

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

We don't create releases when we are updating vnext

If you are not making releases from your default branch (vnext), we will change it to the correct one. Is it master or another branch ?

Also not every push commit creates a new GitHub tag and release. In the documentation we submitted with the last PR, you can check out the exact prerequisite to trigger an output (meaning create a new tag) from the "Bump GH tag" step, which in turn triggers a GitHub release.

The path is this:

Push commit in release branch with SemVer label in the commit message
-> "Bump GH tag" step creates a new GitHub tag and pushes it to the repo
-> CD job evaluates if there is a new GitHub tag and if there is, executes
-> the "Create and publish release" step in the CD job uses the newly created and pushed GitHub tag to create a GitHub release

we generally PR to it

The merge of a PR triggers a push commit, so you can either create a release though your release branch, by committing into it or merging a PR.

If you have any other questions about the automated release process, please let us know! 🙂

Copy link
Member

Choose a reason for hiding this comment

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

We create releases off the master branch.

Copy link
Contributor Author

@aleks-ivanov aleks-ivanov Jun 28, 2021

Choose a reason for hiding this comment

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

@darrelmiller with the last commit:

  • switch the release branch from default_branch to master
  • remove the data gatherer and conditionals handler steps, since they were used specifically for the default_branch as release branch logic

In the current state of the pipeline if there are no errors present, a push commit or PR merge to the master branch with a SemVer label in the title, would deploy (publish packages and create a GitHub release).

Push commits or PR merges to the default_branch (or any other branch, except the default_branch) would trigger the pipeline, but not deploy.

-c Release # `
# -o $env:ARTIFACTS_FOLDER `
# /p:Version=$projectNewVersion
Get-ChildItem -Path src/ -Filter *.csproj -Exclude *Workbench* -File -Recurse | ForEach-Object {
Copy link
Contributor Author

@aleks-ivanov aleks-ivanov May 20, 2021

Choose a reason for hiding this comment

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

Replaced static array of project locations with a more elegant solution.

Copy link
Member

Choose a reason for hiding this comment

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

out of curiosity, any reason why you don't simply target the sln?

Copy link
Contributor Author

@aleks-ivanov aleks-ivanov May 20, 2021

Choose a reason for hiding this comment

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

We just took the build.cmd file as an example and just never gave it a second thought, but now that you mention it unless there is a specific reason not to, we could change the build step to building only the solution instead 🙂

Copy link
Member

Choose a reason for hiding this comment

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

We don't publish the Workbench tool, so I didn't bother building it for publishing nugets. I don't have a problem building it as part of the pipeline. However currently dotnet build can't build the Workbench project because of some error about the GenerateResource task. Not sure what that is about.

-c Release # `
# -o $env:ARTIFACTS_FOLDER `
# /p:Version=$projectNewVersion
Get-ChildItem -Path src/ -Filter *.csproj -Exclude *Workbench* -File -Recurse | ForEach-Object {
Copy link
Member

Choose a reason for hiding this comment

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

out of curiosity, any reason why you don't simply target the sln?

@aleks-ivanov
Copy link
Contributor Author

Also, I forgot to mention that based on this PRs resolution, we will optimize the CodeQL pipeline as well.

@aleks-ivanov
Copy link
Contributor Author

aleks-ivanov commented Jun 21, 2021

@baywet it is an incredible coincidence, but today we discovered that the action for creating release in this pipeline is unmaintained and is quite unstable, so we decided to replace it with a short script utilizing GitHub CLI.

I was just about to commit the change and it will show in this PR, so it would be more convenient for merging.

@aleks-ivanov aleks-ivanov requested a review from baywet June 21, 2021 12:05
.github/workflows/ci-cd.yml Show resolved Hide resolved
.github/workflows/ci-cd.yml Show resolved Hide resolved
baywet
baywet previously approved these changes Jul 5, 2021
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.

GitHub Actions CI/CD pipeline optimizations
4 participants