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

chore: create Gitpod configuration #12210

Merged

Conversation

HonkingGoose
Copy link
Collaborator

@HonkingGoose HonkingGoose commented Oct 19, 2021

Changes:

  • Use a simple Gitpod configuration
    • Use nvm to "pin" node to a specific major version
  • Document how to use Gitpod (or Codespaces) in docs/development/remote-development.md

Context:

This works okay-ish, but it can probably be improved a lot by somebody competent with Docker.

The .gitpod.Dockerfile is cobbled together from the Gitpod programming language reference examples:

  • Java 1
  • JavaScript 2
  • Python 3

The Gitpod docs are licensed under the MIT license, so not sure if that is compatible with our license or not. 4

Docker recommends that you use "multi-stage" builds 5 to reduce container size, but I have no clue how to do that properly, so I'm staying away from that myself.

TODO:

  • Improve Gitpod configuration based on review feedback
  • Figure out why yarn jest has 2 failing tests when running on Gitpod, but no failing tests on GitHub Actions
  • Document how to use Gitpod in our Renovate developer documentation

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please tick one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

Footnotes

  1. https://www.gitpod.io/docs/languages/java#sdkman-in-docker

  2. https://www.gitpod.io/docs/languages/javascript#node-versions

  3. https://www.gitpod.io/docs/languages/python#python-versions

  4. https://github.com/gitpod-io/website/blob/main/LICENSE

  5. https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#use-multi-stage-builds

@rarkins
Copy link
Collaborator

rarkins commented Oct 19, 2021

One point I'm confused about - I'm pretty sure that the last time I tried gitpod, the node/yarn parts worked out of the box. So does their default option do some type of detection and install node for us dynamically?

@HonkingGoose
Copy link
Collaborator Author

HonkingGoose commented Oct 19, 2021

One point I'm confused about - I'm pretty sure that the last time I tried gitpod, the node/yarn parts worked out of the box. So does their default option do some type of detection and install node for us dynamically?

The default gitpod/workspace-full image comes with a lot of tooling, but it also sets some default versions of things like java/yarn/node/python that we probably want to override.

The gitpod/workspace-full image comes with:

  • Node.js v16.11.0
  • nvm 0.39.0
  • yarn 1.22.15
  • Python 3.8.12
  • Java openjdk 11.0.12
  • Git 2.30.1

I'm not sure which is best:

  • Use the .gitpod.yml file and use the init steps to set the versions of tooling
  • Use the custom .gitpod.dockerfile to set the versions of our tooling

.gitpod.Dockerfile Outdated Show resolved Hide resolved
Copy link
Collaborator Author

@HonkingGoose HonkingGoose left a comment

Choose a reason for hiding this comment

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

Questions about RUN command ordering and contents.

.gitpod.Dockerfile Outdated Show resolved Hide resolved
.gitpod.Dockerfile Outdated Show resolved Hide resolved
.gitpod.Dockerfile Outdated Show resolved Hide resolved
.gitpod.yml Outdated Show resolved Hide resolved
.gitpod.yml Outdated Show resolved Hide resolved
.gitpod.Dockerfile Outdated Show resolved Hide resolved
.dockerignore Outdated Show resolved Hide resolved
.gitpod.Dockerfile Outdated Show resolved Hide resolved
.gitpod.yml Outdated Show resolved Hide resolved
@HonkingGoose
Copy link
Collaborator Author

Maybe we're better off waiting until Gitpod supports .devcontainer files? Then we wouldn't need any extra files, or at least much less configuration work.

gitpod-io/gitpod#7721

@HonkingGoose
Copy link
Collaborator Author

HonkingGoose commented Apr 11, 2022

It takes way, way too long to go from "building image" to "starting work" (about 15 minutes or more). That's probably my fault, because I'm cobbling things together in the Dockerfile. 😄

When I start Gitpod from my fork, it gives me a default configuration, which works well for me, as:

I don't know enough Gitpod or Docker to get this PR in a state that we can merge it... 🙈

How about we use the simple Gitpod configuration, and mention in a comment in the file that for "real development work" you should use the .devcontainer on GitHub Codespaces?

@HonkingGoose
Copy link
Collaborator Author

@rarkins How about just using a default Gitpod configuration instead of this complicated stuff? For must of the stuff I do, the default works just fine. We can add a comment to the gitpod file that for "real development work" you should use GitHub Codespaces, as that's what the maintainers use. 😄

.gitpod.yml Outdated Show resolved Hide resolved
@HonkingGoose
Copy link
Collaborator Author

I've tried running yarn jest in Gitpod on the latest main and it's no good. I've aborted the run after giving it a really long time to finish. Here are the stats after I aborted the run:

$ yarn jest
......snip.....
Test Suites: 8 failed, 36 passed, 44 of 444 total
Tests:       78 failed, 4075 passed, 4153 total
Snapshots:   475 passed, 475 total
Time:        2150 s

Example of failing test output:

  ● modules/datasource/go/releases-goproxy › getReleases › supports "off" keyword

    thrown: "Exceeded timeout of 5000 ms for a test.
    Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."

      479 |     });
      480 |
    > 481 |     it('supports "off" keyword', async () => {
          |     ^
      482 |       process.env.GOPROXY = ['https://foo.com', 'https://bar.com', 'off'].join(
      483 |         ','
      484 |       );

      at lib/modules/datasource/go/releases-goproxy.spec.ts:481:5
      at lib/modules/datasource/go/releases-goproxy.spec.ts:266:3
      at Object.<anonymous> (lib/modules/datasource/go/releases-goproxy.spec.ts:7:1)

Maybe the Gitpod environment lacks the power to complete the Jest tests within the timeout, or something else is slowing it down.


I still need a basic Gitpod config so I can use Vale in the repository later (#14835).

We could put a comment in the development docs and the Gitpod config file to warn contributors to only use Gitpod for limited work.

Only use Gitpod to:

- Run Prettier
- Run ESLint
- Run Vale linter

Do not use Gitpod to run the Jest tests.

@HonkingGoose
Copy link
Collaborator Author

@rarkins I can't get the tests to pass when using Gitpod. Are you happy for me to use the default Gitpod configuration, and add a comment like this?

# Use Gitpod for docs editing work only as the tests do not pass (yet).
# For development work, use GitHub Codespaces.

@viceice
Copy link
Member

viceice commented May 3, 2022

@HonkingGoose Is there node v16 on that image? then you need to use yarn jest:16, otherwise jest hungs with oom

@HonkingGoose
Copy link
Collaborator Author

Gitpod uses Node 16 on their default image. :)

@rarkins
Copy link
Collaborator

rarkins commented May 3, 2022

Let's just get something which works!

@HonkingGoose
Copy link
Collaborator Author

Thank you @viceice, running yarn jest:16 gives way better results! 🥳

Still two failed tests though:

=============================== Coverage summary ===============================
Statements   : 99.98% ( 27079/27083 )
Branches     : 98.03% ( 8994/9174 )
Functions    : 100% ( 3285/3285 )
Lines        : 99.98% ( 26643/26647 )
================================================================================
Jest: "global" coverage threshold for statements (100%) not met: 99.98%
Jest: "global" coverage threshold for lines (100%) not met: 99.98%

Summary of all failing tests
 FAIL  lib/util/git/index.spec.ts (288.582 s, 209 MB heap size)
  ● util/git/index › isBranchModified() › should return false when author matches

    expected true to be false or Boolean(false)

      245 |
      246 |     it('should return false when author matches', async () => {
    > 247 |       expect(await git.isBranchModified('renovate/future_branch')).toBeFalse();
          |                                                                    ^
      248 |       expect(await git.isBranchModified('renovate/future_branch')).toBeFalse();
      249 |     });
      250 |

      at Object.<anonymous> (lib/util/git/index.spec.ts:247:68)
          at runMicrotasks (<anonymous>)

  ● util/git/index › isBranchModified() › should return false when author is ignored

    expected true to be false or Boolean(false)

      253 |         gitIgnoredAuthors: ['custom@example.com'],
      254 |       });
    > 255 |       expect(await git.isBranchModified('renovate/custom_author')).toBeFalse();
          |                                                                    ^
      256 |     });
      257 |
      258 |     it('should return true when custom author is unknown', async () => {

      at Object.<anonymous> (lib/util/git/index.spec.ts:255:68)
          at runMicrotasks (<anonymous>)


Test Suites: 1 failed, 453 passed, 454 total
Tests:       2 failed, 8732 passed, 8734 total
Snapshots:   1144 passed, 1144 total
Time:        406.327 s
Ran all test suites.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@rarkins
Copy link
Collaborator

rarkins commented May 5, 2022

Just the git problem remaining?

Copy link
Collaborator Author

@HonkingGoose HonkingGoose left a comment

Choose a reason for hiding this comment

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

I don't have access to GitHub Codespaces, so I need some help from you guys on the Codespaces parts. 😉

docs/development/remote-development.md Outdated Show resolved Hide resolved
docs/development/remote-development.md Outdated Show resolved Hide resolved
docs/development/remote-development.md Outdated Show resolved Hide resolved
@HonkingGoose
Copy link
Collaborator Author

HonkingGoose commented May 5, 2022

Just the git problem remaining?

Pretty much. At least now nearly all tests pass, previously they all failed, due to me using the wrong version of the yarn :jest command. 🙈 😄

Do you need to set a GitHub Personal Access token for all tests to pass?

What would you do if you set up a new development environment from scratch? I'm probably missing some vital step and that's why those two tests fail.

@rarkins
Copy link
Collaborator

rarkins commented May 6, 2022

Pretty much. At least now nearly all tests pass, previously they all failed, due to me using the wrong version of the yarn :jest command. 🙈 😄

I don't mind merging this as-is. Good and done is better than perfect and incomplete.

Do you need to set a GitHub Personal Access token for all tests to pass?

Don't think so? I always have a token though, so maybe I'm missing something.

What would you do if you set up a new development environment from scratch? I'm probably missing some vital step and that's why those two tests fail.

I suspect it's because Gitpod is inserting a git author somewhere as part of the container startup.

viceice
viceice previously approved these changes May 6, 2022
@HonkingGoose HonkingGoose marked this pull request as ready for review May 6, 2022 14:37
@HonkingGoose HonkingGoose requested a review from rarkins May 6, 2022 14:39
@rarkins rarkins merged commit 4e11c71 into renovatebot:main May 7, 2022
@renovate-release
Copy link
Collaborator

🎉 This PR is included in version 32.45.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

@HonkingGoose HonkingGoose deleted the chore/create-gitpod-config-file branch May 7, 2022 20:08
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants