nostalgic-css / NES.css

NES-style CSS Framework | ファミコン風CSSフレームワーク
https://nostalgic-css.github.io/NES.css/
MIT License
20.47k stars 1.64k forks source link

ci: change base image to fix commitlint error #425

Closed SecretBase closed 4 years ago

SecretBase commented 4 years ago

https://github.com/nostalgic-css/NES.css/pull/424

@virtuoushub @guastallaigor

instead of waiting for the upstream image updated. I decide to spend some time to run my own image. So others everyone can moving forward.

I fork the upstream base image and make some changes same as @virtuoushub opened PR for the upstream.

https://github.com/SecretBase/circleci-commitlint-step https://hub.docker.com/r/secretbase/circleci-commitlint/tags

virtuoushub commented 4 years ago

@SecretBase this is much better than my temporary workaround in #424 thanks for doing it.

There is still a small issue w/ that script and CircleCI 2.1 where the PULL_REQUEST_DETAILS=$(curl https://api.github.com/repos/${CIRCLE_PROJECT_USERNAME}${CIRCLE_PROJECT_REPONAME}/pulls/${PULL_REQUEST_NUMBER}) line is returning an error point to: https://developer.github.com/v3/pulls/#get-a-single-pull-request

When I have some more time I am going to dig into it.

virtuoushub commented 4 years ago

The issue in the script seems to stem from CIRCLE_PROJECT_USERNAME resolving to my user name for the pull request and GitHub's API not expecting that to get the PR metadata. Here is what happens in a build triggered by a pull request I made:

$ curl https://api.github.com/repos/virtuoushub/NES.css/pulls/418
{
  "message": "Not Found",
  "documentation_url": "https://developer.github.com/v3/pulls/#get-a-single-pull-request"
}

When I run it manually and use CIRCLE_PROJECT_USERNAME=nostalgic-css, it works as expected:

$  curl https://api.github.com/repos/nostalgic-css/NES.css/pulls/418
{
  "url": "https://api.github.com/repos/nostalgic-css/NES.css/pulls/418",
  "id": 415660899,
...
  "head": {
...
    "sha": "4385140ddf41eeba3c32d61cefc7f2df34d8d482",
...
  },
  "base": {
...
    "sha": "1b91ecfa2ea96d24ed3f66803896f46a268ad0ad",
...
  }
}

[edit - add possible workaround]: one workaround might be to parse CIRCLE_PULL_REQUEST like we are doing for the PR# but also get the CIRCLE_PROJECT_USERNAME

...
# environment setup in CircleCI
CIRCLE_PULL_REQUEST=https://github.com/nostalgic-css/NES.css/pull/418
...
# somewhere right after https://github.com/SecretBase/circleci-commitlint-step/blob/master/commitlint_range.sh#L12
CIRCLE_PROJECT_USERNAME=$(echo "${CIRCLE_PULL_REQUEST}" | cut -d/ -f4)
...
# me testing the parsing logic
$ echo "${CIRCLE_PROJECT_USERNAME}"
nostalgic-css