简体   繁体   English

中继编译器抛出语法错误:在 Github Action 中运行时出现意外的“$”

[英]Relay compiler throws syntax error: Unexpected “$” when running in Github Action

I am using Relay (and Hasura) and hence are required to compile my code ahead of time using the relay-compiler .我正在使用 Relay(和 Hasura),因此需要使用relay-compiler提前编译我的代码。 I can compile the code fine on my local machine, however it always fails when in Github Actions.我可以在本地机器上很好地编译代码,但是在 Github Actions 中它总是失败。

Here is the section of my yml file where is breaks:这是我的yml文件的中断部分:

runs-on: ubuntu-latest
# other steps
- name: Download GraphQL Schema
  run: SECRET=$SECRET ENDPOINT=$ENDPOINT yarn run get-schema
  env:
    SECRET: ${{ secrets.hasura_admin_secret }}
    ENDPOINT: ${{ secrets.graphql_endpoint }}
- name: Test Compile Relay
  run: yarn run relay <<< this fails
- name: Test build
  run: yarn run build

And here are those scripts in my package.json .这是我的package.json中的那些脚本。

"start": "yarn run compile-css && react-scripts start",
"build": "yarn run build-compile-css && react-scripts build",
"get-schema": "yarn run get-graphql-schema -h \"x-hasura-admin-secret=$SECRET\" $ENDPOINT > schema.graphql",
"relay": "yarn run relay-compiler --schema schema.graphql --src src",

It fails with the error:它失败并出现错误:

$ /home/runner/work/<company-name>/<app-name>/node_modules/.bin/relay-compiler --schema schema.graphql --src src
Writing js
ERROR:
Syntax Error: Unexpected "$".

I have verified that schema is downloaded correctly and the paths to the schema and src folder are correct.我已验证模式已正确下载,并且模式和 src 文件夹的路径正确。

Is there specific config or arguments I need to pass to get this working in a CI environment?是否需要传递特定的配置或参数才能使其在 CI 环境中工作?


Update更新

After more testing, I have found that the downloaded file from get-graphql-schema is somehow not correct.经过更多测试,我发现从 get-graphql-schema 下载的文件在某种程度上不正确。 The issue is not there if I commit the schema and use this instead of downloading it.如果我提交架构并使用它而不是下载它,则问题不存在。

I have the understanding it is bad practice to upload graphql.schema files, is this the case?我知道上传graphql.schema文件是不好的做法,是这种情况吗? If so are there are special arguments or set up required to get schema files working correctly in Github Actions?如果是这样,是否需要特殊参数或设置才能使架构文件在 Github Actions 中正常工作?

I have managed to find that when running the get-graphql-schema it Github Actions it add the following line as the first line of the file.我设法发现,在运行get-graphql-schema它 Github Actions 时,它将以下行添加为文件的第一行。 I can remove this via an additional script.我可以通过附加脚本删除它。

schema.graphql模式.graphql

$ /home/runner/work/<company-name>/<app-name>/node_modules/.bin/relay-compiler --schema schema.graphql --src src
schema {
  query: query_root
  mutation: mutation_root
  subscription: subscription_root
}
...

I am unsure though why running this command in github actions will copy the first line.我不确定为什么在 github 操作中运行此命令会复制第一行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM