1

Is there any way to run the compiler on an App Engine application written in Go without continue to serve the application with the development server and instead get an exit code?

Because I want to add a check in my automated tests in Travis that the application actually compiles.

To clarify: I have access to the App Engine SDK / Development Server in Travis, but I dont want to run goapp serve since it never exits.

3
  • Have you considered using a before_script to download the app engine development application? (as per stackoverflow.com/questions/13114334/…)
    – elithrar
    Jul 8, 2014 at 5:19
  • @elithrar I have downloaded the app engine development application, but there seems to be no option to "just compile" the application and not run it. Jul 8, 2014 at 8:34
  • @elithrar Been thinking of using a shell script that starts the app engine dev server and parses the output for 60 seconds, if no ERROR or Traceback appears it is considered a success. But this solution is very dirty. Jul 8, 2014 at 8:35

2 Answers 2

3

Without actually implementing test, your solution looks pretty hacky. Why not use goapp build? Here's my .travis.yml:

language: go
go:
- 1.2.1

# Grab newest version and suck down
install:
    - export FILE=go_appengine_sdk_linux_amd64-$(curl https://appengine.google.com/api/updatecheck | grep release | grep -o '[0-9\.]*').zip
    - curl -O https://storage.googleapis.com/appengine-sdks/featured/$FILE
    - unzip -q $FILE

# Run build and tests
script:
    - ./go_appengine/goapp test ./tests; # If you are testing
    - ./go_appengine/goapp build ./packagedir; # Wherever you keep your stuff

For reference on tests or just to see a project that builds

Edit:

It has been awhile, but I noticed recently that some of my builds randomly break. It is infuriating and I have occasionally hardcoded SDK values to overcome this. No more. Here's a very hacky implementation of grabbing the first featured (and thus hosted as /updatecheck fails to always return a hosted version) of the SDK desired:

export FILE=$(curl https://storage.googleapis.com/appengine-sdks/ | grep -o 'featured/go_appengine_sdk_linux_amd64-[^\<]*' | head -1)

For just the file:

export FILE=$(curl https://storage.googleapis.com/appengine-sdks/ | grep -oP '(?<=featured/)go_appengine_sdk_linux_amd64-[^\<]*' | head -1)
2
  • That is a much better solution, build failed for me due to my project structure being wrong (which I did not know at the time since the dev server always had worked). So this is way more proper. Jul 20, 2014 at 8:12
  • 2
    This gist shows how to automatically download the current App Engine SDK (for Go): gist.github.com/stephanos/d48fd3500614bd83e63e
    – stephanos
    Oct 25, 2014 at 11:06
0

I solved this by adding an empty Unit test at the entry point of the application (main_test.go). This unit test will force the whole application to compile.

Then I execute all unit tests by putting goapp test ./... in the script section.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.