pre-commit-ci / issues

public issues for https://pre-commit.ci
17 stars 4 forks source link

CI Runs inconsistent with local runs #184

Closed hyperupcall closed 1 year ago

hyperupcall commented 1 year ago

describe your issue

https://results.pre-commit.ci does not show same results as local pre-commit runs.

When a PR is made, pre-commit fails with output that look like the following:

prettier.................................................................Failed
- hook id: prettier
- files were modified by this hook

src/test/dependabot/onlyRequired.jsonsrc/negative_test/sil-kit-participant-configuration/full-wrong-additional-root.silkit.yamlsrc/test/azure-iot-edge-deployment-template-4.0/nestededge_isa95_smoke_test_BaseDeployment.jsonsrc/test/remarkrc/plugin-object.jsonsrc/test/template/mvcbasic.jsonsrc/test/function/Kusto.jsonsrc/test/azure-iot-edgeagent-deployment-1.1/deployment.jsonsrc/test/kustomization/metadata.jsonsrc/test/catalog-info/team-a-group-3.jsonsrc/test/catalog-info/all-domains.jsonsrc/test/circleciconfig/workflows.jsonsrc/schemas/json/expo-40.0.0.jsonsrc/negative_test/accelerator/accelerator-invalid-options-name.yamlsrc/schemas/json/httpmockrc.jsonsrc/negative_test/jfrog-pipelines/incorrect_resource_releaseBundle.ymlsrc/test/catalog-info/api-with-$yaml.jsonsrc/test/drupal-config/drupal-config.ymlsrc/test/cloudify/utilities-config-simple.jsonsrc/schemas/json/traefik-v2-file-provider.jsonsrc/test/aurora-1.0/author.aurora.yamlsrc/test/bigquery-table/sample.bigquery.jsonsrc/test/stale/go-ethereum.jsonsrc/negative_test/samt/samt.yamlsrc/schemas/json/block.jsonsrc/negative_test/importmap/unknown_property.jsonsrc/test/all-contributors/minimal.jsonsrc/schemas/json/pm2-ecosystem.jsonsrc/test/aurora-1.0/country.aurora.yamlsrc/negative_test/deployed/.deployed.jsonsrc/test/azure-iot-edge-deployment-template-2.0/module_to_functions_deployment.template.jsonsrc/test/liquibase/dropSequence.jsonsrc/test/azure-iot-edge-deployment-template-4.0/deployment.template.jsonsrc/test/unist/root-full.with-data.jsonsrc/test/lgtm/fprime.jsonsrc/test/one-service-descriptor-schema-0.1/service-descriptor.ymlsrc/test/foundryvtt-module-manifest/remote-highlight-ui_module.jsonsrc/negative_test/unist/void-root.with-position.missing-start-column.jsonsrc/test/catalog-info/api-with-$text.jsonsrc/negative_test/github-workflow/workflow_dispatch-inputs-string-default-bool.yamlsrc/schemas/json/devinit.schema-4.0.jsonsrc/negative_test/bxci.schema-2.x/bxci-stages-wrong-fail-fast.ymlsrc/schemas/json/appsettings.jsonsrc/schemas/json/helmfile.jsonsrc/schemas/json/expo-42.0.0.jsonsrc/negative_test/clangd/external-file-and-server.ymlsrc/schemas/json/swcrc.jsonsrc/test/mimetypes/examples.jsonsrc/schemas/json/azure-deviceupdate-update-manifest-5.jsonsrc/test/travis/addon-snaps.jsonsrc/test/jsconfig/jsconfig-extends-single.jsonsrc/test/label-commenter-config/stellarium.jsonsrc/test/schema-org-contact-point/tollfree.jsonsrc/test/catalog-info/podcast-api-component.jsonsrc/test/clang-format/GNU.clang-format.ymlsrc/test/huskyrc/huskyrc-test.jsonsrc/test/tmuxinator/sample.deprecations.ymlsrc/test/package/issue-2957.jsonsrc/test/liquibase/update.jsonsrc/test/azure-iot-edge-deployment-template-4.0/nestededge_bottomLayerBaseDeployment_connectivity_mqtt.template.jsonsrc/test/github-workflow/2579-1.yamlsrc/test/img-catapult-psp-1.0.0/contents-min.yamlsrc/test/vtesttree-schema/empty-tree-v2.vtesttree.yamlsrc/negative_test/bxci.schema-2.x/bxci-missing-output-package-publish.ymlsrc/test/cloudify/openstack-blueprint.jsonsrc/test/license-report-config/full-license-report-config.jsonsrc/test/liquibase/dropIndex.jsonsrc/schemas/json/azure-iot-edgehub-deployment-1.1.jsonsrc/test/agripparc-1.3/complete-ts-agripparc.jsonsrc/schemas/json/sarif-2.1.0-rtm.2.jsonsrc/schemas/json/commands.jsonsrc/negative_test/chrome-manifest/v3_global_command_key_must_include_shift.jsonsrc/schemas/json/azure-deviceupdate-update-manifest-4.jsonsrc/schemas/json/nest-cli.jsonsrc/schemas/json/typewiz.jsonsrc/test/cloudify/k8s-test-stateful-set.jsonsrc/test/ts-force-config/simple.jsonsrc/test/appveyor/appvyor.ymlsrc/test/function/SasToken.jsonsrc/test/schema-org-place/example3.jsonsrc/test/function/SendGrid.jsonsrc/schemas/json/minecraft-template-pool.jsonsrc/schemas/json/webjob-publish-settings.jsonsrc/schemas/json/minecraft-dimension.jsonsrc/schemas/json/micro.jsonsrc/test/global/valid-rollfoward.jsonsrc/test/sponge-mixins/test1.jsonsrc/test/tslint/tslint-test6.jsonsrc/test/jsonld/w3c-sample.jsonsrc/test/asmdef/test03.asmdef.jsonsrc/schemas/json/foundryvtt-base-package-manifest.jsonsrc/test/bxci.schema-2.x/bxci-disable-commit-threshold.ymlsrc/test/catalog-info/playback-lib-component.jsonsrc/test/pre-commit-hooks/pre-commit-hooks.jsonsrc/test/tmuxinator/noroot.ymlsrc/schemas/json/airlock-microgateway-3.1.jsonsrc/test/webextension/webcompat-reporter.jsonsrc/schemas/json/proxies.jsonsrc/negative_test/accelerator/accelerator-invalid-engine-transform-type.yamlsrc/test/detekt-1.22.0/generated-detekt-config.jsonsrc/test/rust-toolchain/custom_toolchain02.jsonsrc/negative_test/jfrog-pipelines/incorrect_resource_cronTrigger.ymlsrc/schemas/json/csscomb.jsonsrc/test/sprite/example.jsonsrc/schemas/json/sarif-2.0.0-csd.2.beta.2019-01-09.jsonsrc/test/prometheus.rules/rules.jsonsrc/negative_test/accelerator/accelerator-invalid-engine-strategy.yamlsrc/schemas/json/detekt-1.14.1.jsonsrc/test/tslint/tslint-test4.jsonsrc/test/minecraft-predicate/is-sneaking.jsonsrc/test/cargo-make/cargo-make.jsonsrc/test/kustomization/buildMetadata.jsonsrc/test/ninjs-1.2/ninjs-1.2-infosource-test.jsonsrc/test/github-workflow/1567.yamlsrc/negative_test/github-issue-forms/check_additionalProperties_at_body.jsonsrc/negative_test/sergen/wrong-capitalization-of-tablename.jsonsrc/schemas/json/mimetypes.jsonsrc/test/bxci.schema-1.0.1/bxci-no-jenkins.ymlsrc/test/size-limit/.size-limit2.jsonsrc/test/codecov/codecov-example-3.jsonsrc/schemas/json/foundryvtt-system-manifest.jsonsrc/test/unist/root-full.jsonsrc/test/github-workflow/call-reusable-workflow-local-file.yamlsrc/test/circleciconfig/machine-executor.jsonsrc/test/cloudify/ansible-playbook-compute-blueprint.jsonsrc/test/expo-40.0.0/hotdog-app.jsonsrc/test/minecraft-item-modifier/edit-durability.jsonsrc/test/es6importsorterrc/es6importsorterrc-test.jsonsrc/schemas/json/appsscript.jsonsrc/schemas/json/lsdlschema-2.0.jsonsrc/test/appsettings/umbraco.jsonsrc/schemas/json/ninjs-2.0.jsonsrc/test/bamboo-spec/bamboo-test-labels.ymlsrc/test/azure-iot-edgehub-deployment-1.0/deployment.jsonsrc/test/ninjs-1.3/007_trust_indicator.jsonsrc/test/github-issue-config/official-example.jsonsrc/test/micro/expect-no-errors-for-correct-property-values.jsonsrc/test/sil-kit-participant-configuration/logging.silkit.yamlsrc/test/liquibase/addDefaultValue.jsonsrc/schemas/json/safebox-schema-v1.0.0.jsonsrc/schemas/json/package.manifest-7.0.0.jsonsrc/schemas/json/jsbeautifyrc.jsonsrc/schemas/json/sarif-external-property-file-2.1.0-rtm.2.jsonsrc/schemas/json/cryproj.jsonsrc/test/travis/deployment-heroku.jsonsrc/test/circleciconfig/contexts.jsonsrc/test/semantic-release/example1.jsonsrc/schemas/json/huskyrc.jsonsrc/schemas/json/sarif-external-property-file-2.1.0-rtm.1.jsonsrc/test/global/simple-version.jsonsrc/test/remarkrc/full-settings.jsonsrc/test/minecraft-lang/default.jsonsrc/test/schema-catalog/minimal.jsonsrc/test/tsconfig/tsconfig.jsonsrc/test/rehyperc/preferUnquoted.jsonsrc/test/travis/notification-secure-list.jsonsrc/schemas/json/github-funding.jsonsrc/schemas/json/gitversion.jsonsrc/test/appveyor/reference.jsonsrc/schemas/json/vim-addon-info.jsonsrc/schemas/json/github-workflow-template-properties.jsonsrc/test/azure-iot-edge-deployment-template-2.0/stress_deployment.template.jsonsrc/test/asconfig-schema/respect-inheritence_asconfig.jsonsrc/test/factorial-drupal-breakpoints-css-0.2.0/optional.jsonsrc/test/rust-toolchain/custom_toolchain01.jsonsrc/test/github-workflow/with-from-json.yamlsrc/test/drone/kubernetes_volumes.yamlsrc/schemas/json/cheatsheets.jsonsrc/test/grunt-jshint-task/without-jshint-options.jsonsrc/test/tslint/tslint-test18.jsonsrc/test/appsettings/umbraco-more-settings.jsonsrc/test/lego/lego-object-format.jsonsrc/test/tslint/tslint-test16.jsonsrc/test/catalog-info/wayback-archive-ingestion-component.jsonsrc/schemas/json/remarkrc.jsonsrc/test/webextension/open-irc-links.jsonsrc/test/typings/typings-test3.jsonsrc/schemas/json/sponge-mixins.jsonsrc/negative_test/jfrog-pipelines/incorrect_resource_outgoingWebhook.ymlsrc/test/schema-org-contact-point/billing.jsonsrc/negative_test/monika-config-schema/bad-request.ymlsrc/negative_test/azure-deviceupdate-import-manifest-4.0/invalidstep-importmanifest.jsonsrc/test/github-workflow/containers.yamlsrc/schemas/json/azure-iot-edgeagent-deployment-1.0.jsonsrc/test/drupal-links-menu/drupal-links-menu.ymlsrc/test/yamllint/jacket.jsonsrc/schemas/json/dart-build.jsonsrc/negative_test/clang-format/invalid.clang-format.ymlsrc/test/schema-org-thing/thing1.jsonsrc/schemas/json/mycode.jsonsrc/test/tmuxinator/sample.ymlsrc/test/vtesttree-schema/full-tree.vtesttree.yamlsrc/test/ninjs-2.0/003_schema_only.jsonsrc/test/grunt-cssmin-task/without-options.jsonsrc/schemas/json/csslintrc.jsonsrc/test/comet/env.jsonsrc/test/tmuxinator/sample_literals_as_window_name.ymlsrc/test/package.manifest/youtube.jsonsrc/test/catalog-info/team-a-group-2.jsonsrc/negative_test/github-action/empty_json_must_always_fail.jsonsrc/test/docfx/docfx-seed.jsonsrc/schemas/json/tizen_workspace.jsonsrc/test/azure-iot-edge-deployment-template-4.0/nestededge_bottomLayerBaseDeployment_long_haul_mqtt.template.jsonsrc/test/airlock-microgateway-3.2/config.jsonsrc/test/mta/mta-test.jsonsrc/test/sergen/extends-version.jsonsrc/test/ninjs-1.3/001_ninjs_example.jsonsrc/test/rehyperc/upperDoctype.jsonsrc/schemas/json/drupal-permissions.jsonsrc/test/tslint/tslint-test9.jsonsrc/test/liquibase/dropUniqueConstraint.jsonsrc/schemas/json/install.jsonsrc/test/kustomization/helmCharts.jsonsrc/schemas/json/expo-37.0.0.jsonsrc/test/remarkrc/listItemIndent.jsonsrc/test/package/exports-test2.jsonsrc/test/cloudify/k8s-file-test.jsonsrc/test/azure-iot-edgehub-deployment-1.1/deployment.jsonsrc/test/typings/typings-test6.jsonsrc/test/postcssrc/plugins.jsonsrc/schemas/json/vsls.jsonsrc/negative_test/jfrog-pipelines/incorrect_step_promoteBuild.ymlsrc/test/rehyperc/fragment.jsonsrc/test/azure-iot-edge-deployment-template-2.0/dm_module_to_module_deployment.jsonsrc/test/kustomization/secretGenerator.j

(output truncated)

But, when I run it locally, everything works:

$ pre-commit run
prettier.................................................................Passed
$ pre-commit run --all-files
prettier.................................................................Passed
pre-commit run --all-files --hook-stage pre-commit prettier
prettier.................................................................Passed

Of course, things work when manually running Prettier.

$ ./src/node_modules/.bin/prettier --check src/test/dependabot-2.0/example.json
Checking formatting...
All matched files use Prettier code style!

Here are two links to results.pre-commit.ci where this has occurred.

More information

$ pre-commit --version
pre-commit 3.3.3
$ npm explain prettier
npm explain prettier
prettier@2.8.3 dev
node_modules/prettier
  dev prettier@"^2.8.3" from the root project
  peer prettier@"^2.3.2" from prettier-plugin-sort-json@1.0.0
  node_modules/prettier-plugin-sort-json
    dev prettier-plugin-sort-json@"^1.0.0" from the root project
$ npm explain prettier-plugin-sort-json
prettier-plugin-sort-json@1.0.0 dev
node_modules/prettier-plugin-sort-json
  dev prettier-plugin-sort-json@"^1.0.0" from the root project

pre-commit --version

3.3.3

.pre-commit-config.yaml

---
repos:
  - repo: https://github.com/pre-commit/mirrors-prettier
    rev: "v3.0.0"
    hooks:
      - id: prettier
        types_or: [yaml, json, javascript, css, markdown]
        always_run: true
        additional_dependencies:
          - prettier@2.8.3
          - prettier-plugin-sort-json@1.0.0
asottile commented 1 year ago

fwiw I get what CI gets

you can reproduce with the public docker image as well (it is mentioned in your run)

hyperupcall commented 1 year ago

Any documentation or pointers for using the public docker image? Couldn't find anything conclusive on the website or the pacakge page or in pre-commit-ci/runner-image or in the public issues.

I tried

docker run -u $(id -u):$(id -g) -v $(pwd):/src:rw,Z --workdir /src --rm -it ghcr.io/pre-commit-ci/runner-image --help
[dumb-init] --help: No such file or directory

and

docker run -u $(id -u):$(id -g) -v $(pwd):/src:rw,Z --workdir /src --rm -it ghcr.io/pre-commit-ci/runner-image /src/pre-commit-config.yaml
[dumb-init] /src/pre-commit-config.yaml: No such file or directory

among other things

asottile commented 1 year ago

it's just a normal docker image, the command goes after the image

hyperupcall commented 1 year ago

Oh I see, I thought it was one of those images that set the ENTRYPOINT to the command line tool itself, and I didn't recognize the changes Docker made to PID 1 in the process namespace.

Anyways, I got things to run, but I get the same result

$ PRE_COMMIT_HOME=/src docker run -e PRE_COMMIT_HOME -u $(id -u):$(id -g) -v $(pwd):/src:rw,Z --workdir /src --rm -it ghcr.io/pre-commit-ci/runner-image:2023-03-25-6547f65 pre-commit run --all-files
prettier.................................................................Passed

So uh, idk how else to debug this unless you ran something totally different

asottile commented 1 year ago
$ docker run --rm -t -v $PWD:/src:rw -v $PWD/../pc:/pc:rw --workdir /src -u $(id -u):$(id -g) --userns=keep-id ghcr.io/pre-commit-ci/runner-image:2023-03-25-6547f65-full bash -c 'pre-commit run --all-files'

...

produces this diff:

diff --git a/src/schemas/json/tmlanguage.json b/src/schemas/json/tmlanguage.json
index 4b4bc42..e924c8b 100644
--- a/src/schemas/json/tmlanguage.json
+++ b/src/schemas/json/tmlanguage.json
@@ -1,6 +1,6 @@
 {
-  "$schema": "http://json-schema.org/draft-07/schema#",
   "$ref": "#/definitions/root",
+  "$schema": "http://json-schema.org/draft-07/schema#",
   "definitions": {
     "root": {
       "allOf": [
@@ -40,9 +40,7 @@
               "type": "string"
             }
           },
-          "required": [
-            "scopeName"
-          ]
+          "required": ["scopeName"]
         }
       ]
     },
@@ -64,9 +62,7 @@
           }
         }
       },
-      "required": [
-        "patterns"
-      ]
+      "required": ["patterns"]
     },
     "captures": {
       "type": "object",
@@ -164,66 +160,38 @@
         "begin": {
           "anyOf": [
             {
-              "required": [
-                "end"
-              ]
+              "required": ["end"]
             },
             {
-              "required": [
-                "while"
-              ]
+              "required": ["while"]
             }
           ]
         },
-        "end": [
-          "begin"
-        ],
-        "while": [
-          "begin"
-        ],
+        "end": ["begin"],
+        "while": ["begin"],
         "contentName": {
           "anyOf": [
             {
-              "required": [
-                "begin",
-                "end"
-              ]
+              "required": ["begin", "end"]
             },
             {
-              "required": [
-                "begin",
-                "while"
-              ]
+              "required": ["begin", "while"]
             }
           ]
         },
         "beginCaptures": {
           "anyOf": [
             {
-              "required": [
-                "begin",
-                "end"
-              ]
+              "required": ["begin", "end"]
             },
             {
-              "required": [
-                "begin",
-                "while"
-              ]
+              "required": ["begin", "while"]
             }
           ]
         },
-        "whileCaptures": [
-          "begin",
-          "while"
-        ],
-        "endCaptures": [
-          "begin",
-          "end"
-        ],
-        "applyEndPatternLast": [
-          "end"
-        ]
+        "whileCaptures": ["begin", "while"],
+        "endCaptures": ["begin", "end"],
+        "applyEndPatternLast": ["end"]
       }
     },
     "name": {
diff --git a/src/test/tmlanguage/tmlanguage.json b/src/test/tmlanguage/tmlanguage.json
index 45200b6..2b1a408 100644
--- a/src/test/tmlanguage/tmlanguage.json
+++ b/src/test/tmlanguage/tmlanguage.json
@@ -1,6 +1,5 @@
 {
   "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
-  "scopeName": "source.terminfo",
   "name": "terminfo",
   "patterns": [
     {
@@ -16,5 +15,6 @@
         }
       ]
     }
-  }
+  },
+  "scopeName": "source.terminfo"
 }
hyperupcall commented 1 year ago

Thank you for your reply! (sorry I couldn't respond earlier) It looked like I was missing the $PWD/../pc:/pc:rw argument. The command now works and my files have properly been changed. I appreciate your help!