Drone

Enhancing "drone starlark convert" runtime check

Hello Drone community.
I would like to discuss about the possibility to enhance drone starlark convert's runtime error check.

For example the following runtime happens with this .drone.star file.

$ drone starlark convert --stdout
2020/04/14 22:20:45 yaml: unmarshal errors:
  line 1: cannot unmarshal !!seq into string

This error is created intentionally by the latest one commit on my forked repository’s branch of simde project.
And this error is what I actually faced, when I was working on the .drone.star file in the project.

How do you think adding the line number of the .drone.star file causing the error? It helps the debugging.

Or what is the best practice to debug in this case?

The last document has an invalid commands section. The commands section should be an array of strings, however, one of the items in the array is an array.

{
  "platform": {
    "os": "linux", 
    "arch": "arm64"
  }, 
  "kind": "pipeline", 
  "type": "docker", 
  "name": "fedora clang arm64 flags", 
  "steps": [
    {
      "environment": {
        "CC": "clang", 
        "CXX": "clang++"
      }, 
      "failure": "ignore", 
      "commands": [
        "uname -m", 
        "cat /proc/cpuinfo", 
        "dnf install -y clang ninja-build git-core python3-pip", 
        "pip3 install meson", 
        "git submodule --quiet update --init --recursive", 
-        [
-          "ARCH_FLAGS=$(rpm -E '%{optflags}' | sed -e 's| -fstack-clash-protection||' -e 's| -specs=[^ ]*||g')", 
-          "mkdir -p build", 
-          "cd build", 
-          "CFLAGS=\"$ARCH_FLAGS\" CXXFLAGS=\"$ARCH_FLAGS\" meson ..", 
-          "ninja -v", 
-          "./test/run-tests"
-        ]
      ], 
      "image": "fedora:rawhide", 
      "name": "test"
    }
  ]
}

I was able to debug by running this command which prints the raw results without formatting or linting:

drone starlark --stdout --format=false

Great! Thank you for debugging, and share the useful way drone starlark --stdout --format=false.

This error is created intentionally by the latest one commit on my forked repository’s branch of simde project.

As I said above, this error was created to report here. I knew the cause of the error before reporting it here.

On the timeline,

  1. I faced the error
  2. I fixed the error
  3. I reported to discuss the topic here reproducing the error.

So what do you think about improving the drone starlark convert command to show the error message with the actual .drone.star line number (N) and the element that causes the runtime error (yaml [item number] [“steps”][0][“commands”][5]) like this?

$ drone starlark convert --stdout
2020/04/14 22:20:45 yaml: unmarshal errors:
  line N: cannot unmarshal !!seq into string at yaml [item number] ["steps"][0]["commands"][5].

I do not think this is possible because we have no way to associate a line in the yaml with the corresponding line in the starlark program that caused the problem.

Sure. Thanks for the answer.