gperdomor / nx-tools

Nx Workspaces builders and tools
MIT License
346 stars 53 forks source link

Git fallback not working properly #975

Open an-ky opened 6 months ago

an-ky commented 6 months ago

I run nx-containers using Buildbot as our CI.

The command npx nx affected --base=origin/development --head=<sha> --target=container --parallel=1 fails with the following error:

Unsupported CI Provider... Using Local Environment as fallback
[command]/usr/bin/git log -1 --pretty=format:%ae
me@mycompany.example[command]/usr/bin/git symbolic-ref HEAD
fatal: ref HEAD is not a symbolic ref
>  Removing temp folder /tmp/docker-build-push-aemX4D 
 NX   The process '/usr/bin/git' failed with exit code 128
Pass --verbose to see the stacktrace.

Detecting an unsupported CI is correct because ci-info does not recognize buildbot and ci-context cannot handle it. The fallback to Git tries to fetch the current SHA using Git.ref, but I wonder why the exception is not handled correctly and the fallback using git tag is used - which I assume because the last command printed is git symbolic-link HEAD followed by the error message.

The unit test do not cover this case, AFAICS. I tried to enhance them but my skills in TS are marginal at the moment.

Here is my package.json

{
  "name": "web-apps",
  "version": "0.0.0",
  "scripts": { 
  ...
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~15.1.0",
    "@angular/cdk": "^15.1.1",
    "@angular/common": "~15.1.0",
    "@angular/compiler": "~15.1.0",
    "@angular/core": "~15.1.0",
    "@angular/forms": "~15.1.0",
    "@angular/material": "^15.1.1",
    "@angular/material-moment-adapter": "^15.2.8",
    "@angular/platform-browser": "~15.1.0",
    "@angular/platform-browser-dynamic": "~15.1.0",
    "@angular/router": "~15.1.0",
    "@asymmetrik/ngx-leaflet": "^15.0.1",
    "@ngrx/component-store": "~15.0.0",
    "@ngrx/data": "~15.0.0",
    "@ngrx/effects": "~15.0.0",
    "@ngrx/entity": "~15.0.0",
    "@ngrx/router-store": "~15.0.0",
    "@ngrx/store": "~15.0.0",
    "@nrwl/angular": "15.5.2",
    "angular-plotly.js": "4.0.4",
    "keycloak-angular": "13.0.0",
    "keycloak-js": "20.0.3",
    "leaflet": "^1.9.3",
    "leaflet.tilelayer.colorfilter": "^1.2.5",
    "lodash": "^4.17.21",
    "moment": "^2.29.4",
    "ngx-mat-select-search": "^7.0.0",
    "plotly.js-dist-min": "^2.16.5",
    "rxjs": "~7.5.0",
    "tslib": "^2.6.2",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^15.2.6",
    "@angular-eslint/eslint-plugin": "~15.0.0",
    "@angular-eslint/eslint-plugin-template": "~15.0.0",
    "@angular-eslint/template-parser": "~15.0.0",
    "@angular/cli": "~15.1.0",
    "@angular/compiler-cli": "~15.1.0",
    "@angular/language-service": "~15.1.0",
    "@compodoc/compodoc": "^1.1.19",
    "@ngrx/schematics": "~15.0.0",
    "@ngrx/store-devtools": "~15.0.0",
    "@nrwl/cypress": "15.5.2",
    "@nrwl/eslint-plugin-nx": "15.5.2",
    "@nrwl/jest": "15.5.2",
    "@nrwl/linter": "15.5.2",
    "@nrwl/workspace": "15.5.2",
    "@nx-tools/nx-container": "^5.2.0",
    "@nx-tools/container-metadata": "^5.2.0",
    "@types/jest": "28.1.1",
    "@types/leaflet": "^1.9.0",
    "@types/lodash": "^4.14.185",
    "@types/node": "16.11.7",
    "@types/plotly.js-dist-min": "^2.3.1",
    "@typescript-eslint/eslint-plugin": "^5.36.1",
    "@typescript-eslint/parser": "^5.36.1",
    "cypress": "^12.2.0",
    "eslint": "~8.15.0",
    "eslint-config-prettier": "8.1.0",
    "eslint-plugin-cypress": "^2.10.3",
    "jest": "28.1.1",
    "jest-environment-jsdom": "28.1.1",
    "jest-junit": "^15.0.0",
    "jest-preset-angular": "~12.2.3",
    "nx": "~18.0.4",
    "prettier": "^2.6.2",
    "ts-jest": "28.0.5",
    "ts-node": "10.9.1",
    "typescript": "~4.8.2"
  }
}
gperdomor commented 4 months ago

@an-ky can you try again with version 6.0.0 please?