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

init not working as expected with pre-build #4838

Closed
jmcelreavey opened this issue Jul 15, 2021 · 8 comments · Fixed by #4903
Closed

init not working as expected with pre-build #4838

jmcelreavey opened this issue Jul 15, 2021 · 8 comments · Fixed by #4903

Comments

@jmcelreavey
Copy link

Bug description

I currently have the following logic in place:

tasks:
  - before: |
      printf "\n[settings]\napi_key = $WAKA_TIME_API_KEY\n" > ~/.wakatime.cfg
    prebuild: |
      docker-compose up -d
      yarn install
      yarn run database:migrate
    command: |
      docker-compose down
      docker network prune -f
      yarn run dev

This works perfectly, however, the documentation is telling me prebuild has been deprecated and I should replace it with init however when I do this it doesn't rebuild the init step, it runs during startup.

Steps to reproduce

Gitpod up the repository:
https://gitpod.io/#https://github.com/jmcelreavey/dev-job

Expected behavior

I would expect the GitHub pre-build functionality to see the init and run it prior to me starting the workspace

Example repository

https://github.com/jmcelreavey/dev-job

Anything else?

No response

@csweichel
Copy link
Contributor

/schedule

@faisal-m16
Copy link

Same Issue. When creating a new workspace with extension no task is running.

tasks:
  - name: Run Client
    before: cd client
    init: yarn install
    command: yarn start
    env:
      DANGEROUSLY_DISABLE_HOST_CHECK: true
    openMode: tab-after
  - name: Run Server
    init: npm install
    command: npm run server
    openMode: tab-after

vscode:
  extensions:
    - formulahendry.auto-close-tag
    - coenraads.bracket-pair-colorizer
    - pkief.material-icon-theme
    - eamodio.gitlens
    - usernamehw.errorlens
    - >-
      https://marketplace.visualstudio.com/_apis/public/gallery/publishers/eg2/vsextensions/tslint/1.0.47/vspackage

ports:
  - port: 3000
    onOpen: open-browser
    visibility: public
  - port: 4000
    onOpen: ignore
    visibility: public

@faisal-m16
Copy link

Update: After removing env from task Run Client it worked fine. But I am still confused why it was not running with env

@jmcelreavey
Copy link
Author

is 'env' a useable option? Have you tried the command: gp env DANGEROUSLY_DISABLE_HOST_CHECK=true

@faisal-m16
Copy link

https://www.gitpod.io/docs/references/gitpod-yml#tasksnenv env in tasks i defined here. I followed documentation.

I did other workaround in command: DANGEROUSLY_DISABLE_HOST_CHECK: true yarn start.

@csweichel
Copy link
Contributor

/assign

@csweichel
Copy link
Contributor

@jmcelreavey I'm afraid I cannot re-produce the issue. The repository you linked behaves as intended: the init task gets run during the prebuild, and is not re-executed when the workspace starts.

Note: we modify the terminal history to make it look like the task just ran. You can tell that the command ran as part of the prebuild because the log output appears before

🤙 This task ran as a workspace prebuild
🎉 Well done on saving 2 minutes

To make sure this behaviour doesn't break in the future (and as one more step to verify the correct behaviour), I've written a bunch of unit tests: #4903

@csweichel
Copy link
Contributor

@faisal-m16 Unfortunately prebuilds don't give a whole lot of feedback when the .gitpod.yml has validation errors, which is what I suspect is the case here. We've recently added some functionality that provides feedback regarding the .gitpod.yml when opening the workspace. Please check if you see any validation errors when opening the workspace regularly.

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

Successfully merging a pull request may close this issue.

4 participants