在Travis中编译App Engine应用程序

时间:2014-07-07 15:46:20

标签: google-app-engine go travis-ci

有没有办法在Go编写的App Engine应用程序上运行编译器而不继续使用开发服务器为应用程序提供服务而是获取退出代码?

因为我想在Travis的自动化测试中添加一个检查应用程序实际编译的内容。

澄清:我可以访问Travis中的App Engine SDK / Development Server,但我不想运行goapp serve,因为它永远不会退出。

2 个答案:

答案 0 :(得分:3)

如果没有实际执行测试,您的解决方案看起来很糟糕。为什么不使用goapp build?这是我的.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

编辑:

已经有一段时间了,但我最近注意到我的一些版本会随机破坏。这是令人愤怒的,我偶尔硬编码SDK值来克服这个问题。不再。这是一个非常hacky实现的抓取所需的SDK的第一个特色(因此托管为/ updatecheck无法始终返回托管版本):

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

仅适用于文件:

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

答案 1 :(得分:0)

我通过在应用程序的入口点(main_test.go)添加一个空的Unit测试来解决这个问题。此单元测试将强制整个应用程序进行编译。

然后我通过在脚本部分中添加 goapp test ./...来执行所有单元测试。