User:TCipriani (WMF)/Gerrit/Tutorial/Materialize

From mediawiki.org

πŸ§‘πŸ½β€πŸ’» Gerrit for Product Analytics–Tutorial


Materialize Changes

Now you can make changes to your repo. Here we'll follow along with the Creating a new schema tutorial from Wikitech.

# 1️⃣ Step 1

Change to your newly cloned schemas/event/secondary directory and run npm i to install all the software needed to make a new schema.

❇️ npm i
$ cd schemas/event/secondary
$ npm i
> schemas-event-secondary@1.0.0 postinstall
> $(npm bin)/jsonschema-tools install-git-hook

[2021-10-28 00:52:08.690 +0000]: Saving jsonschema-tools materialize-modified pre-commit hook to /home/user/src/schemas/event/secondary/.git/hooks/pre-commit

added 249 packages, and audited 250 packages in 9s

Now you'll have a node_modules directory inside the schemas/event/secondary directory.

schemas/event/secondary/node_modules
β”œβ”€β”€ acorn
β”œβ”€β”€ acorn-jsx
β”œβ”€β”€ ajv
β”œβ”€β”€ ansi-colors
β”œβ”€β”€ ansi-escapes
β”œβ”€β”€ ansi-regex
β”œβ”€β”€ ansi-styles
β”œβ”€β”€ argparse
β”œβ”€β”€ args
β”œβ”€β”€ astral-regex
β”œβ”€β”€ atomic-sleep
β”œβ”€β”€ @babel
β”œβ”€β”€ balanced-match
β”œβ”€β”€ bluebird
β”œβ”€β”€ brace-expansion
β”œβ”€β”€ browser-stdout
β”œβ”€β”€ call-me-maybe
β”œβ”€β”€ callsites
β”œβ”€β”€ camelcase
β”œβ”€β”€ chalk
β”œβ”€β”€ chardet
β”œβ”€β”€ cli-cursor
β”œβ”€β”€ cliui
β”œβ”€β”€ cli-width
β”œβ”€β”€ color-convert
β”œβ”€β”€ color-name
β”œβ”€β”€ compute-gcd
β”œβ”€β”€ compute-lcm
β”œβ”€β”€ concat-map
β”œβ”€β”€ cross-spawn
β”œβ”€β”€ dateformat
β”œβ”€β”€ debug
β”œβ”€β”€ decamelize
β”œβ”€β”€ deep-is
β”œβ”€β”€ define-properties
β”œβ”€β”€ diff
β”œβ”€β”€ doctrine
β”œβ”€β”€ drange
β”œβ”€β”€ emoji-regex
β”œβ”€β”€ end-of-stream
β”œβ”€β”€ es-abstract
β”œβ”€β”€ escape-string-regexp
β”œβ”€β”€ eslint
β”œβ”€β”€ eslint-scope
β”œβ”€β”€ eslint-utils
β”œβ”€β”€ eslint-visitor-keys
β”œβ”€β”€ espree
β”œβ”€β”€ esprima
β”œβ”€β”€ esquery
β”œβ”€β”€ esrecurse
β”œβ”€β”€ es-to-primitive
β”œβ”€β”€ estraverse
β”œβ”€β”€ esutils
β”œβ”€β”€ external-editor
β”œβ”€β”€ fast-deep-equal
β”œβ”€β”€ fast-json-stable-stringify
β”œβ”€β”€ fast-levenshtein
β”œβ”€β”€ fast-redact
β”œβ”€β”€ fast-safe-stringify
β”œβ”€β”€ figures
β”œβ”€β”€ file-entry-cache
β”œβ”€β”€ find-up
β”œβ”€β”€ flat
β”œβ”€β”€ flat-cache
β”œβ”€β”€ flatstr
β”œβ”€β”€ flatted
β”œβ”€β”€ format-util
β”œβ”€β”€ fs-extra
β”œβ”€β”€ fs.realpath
β”œβ”€β”€ functional-red-black-tree
β”œβ”€β”€ function-bind
β”œβ”€β”€ get-caller-file
β”œβ”€β”€ glob
β”œβ”€β”€ globals
β”œβ”€β”€ glob-parent
β”œβ”€β”€ graceful-fs
β”œβ”€β”€ growl
β”œβ”€β”€ @hapi
β”œβ”€β”€ has
β”œβ”€β”€ has-flag
β”œβ”€β”€ has-symbols
β”œβ”€β”€ he
β”œβ”€β”€ hosted-git-info
β”œβ”€β”€ iconv-lite
β”œβ”€β”€ ignore
β”œβ”€β”€ import-fresh
β”œβ”€β”€ imurmurhash
β”œβ”€β”€ inflight
β”œβ”€β”€ inherits
β”œβ”€β”€ inquirer
β”œβ”€β”€ is-buffer
β”œβ”€β”€ is-callable
β”œβ”€β”€ is-date-object
β”œβ”€β”€ isexe
β”œβ”€β”€ is-extglob
β”œβ”€β”€ is-fullwidth-code-point
β”œβ”€β”€ is-glob
β”œβ”€β”€ is-regex
β”œβ”€β”€ is-symbol
β”œβ”€β”€ jmespath
β”œβ”€β”€ joycon
β”œβ”€β”€ jsonfile
β”œβ”€β”€ jsonpath-plus
β”œβ”€β”€ json-schema-compare
β”œβ”€β”€ json-schema-faker
β”œβ”€β”€ json-schema-merge-allof
β”œβ”€β”€ json-schema-ref-parser
β”œβ”€β”€ json-schema-traverse
β”œβ”€β”€ json-stable-stringify-without-jsonify
β”œβ”€β”€ js-tokens
β”œβ”€β”€ js-yaml
β”œβ”€β”€ leven
β”œβ”€β”€ levn
β”œβ”€β”€ locate-path
β”œβ”€β”€ lodash
β”œβ”€β”€ log-symbols
β”œβ”€β”€ lru-cache
β”œβ”€β”€ mimic-fn
β”œβ”€β”€ minimatch
β”œβ”€β”€ minimist
β”œβ”€β”€ mkdirp
β”œβ”€β”€ mocha
β”œβ”€β”€ mri
β”œβ”€β”€ ms
β”œβ”€β”€ mute-stream
β”œβ”€β”€ natural-compare
β”œβ”€β”€ netmask
β”œβ”€β”€ nice-try
β”œβ”€β”€ node-environment-flags
β”œβ”€β”€ node-fetch
β”œβ”€β”€ object.assign
β”œβ”€β”€ object.getownpropertydescriptors
β”œβ”€β”€ object-inspect
β”œβ”€β”€ object-keys
β”œβ”€β”€ once
β”œβ”€β”€ onetime
β”œβ”€β”€ ono
β”œβ”€β”€ optionator
β”œβ”€β”€ os-tmpdir
β”œβ”€β”€ parent-module
β”œβ”€β”€ path-exists
β”œβ”€β”€ path-is-absolute
β”œβ”€β”€ path-key
β”œβ”€β”€ pino
β”œβ”€β”€ pino-pretty
β”œβ”€β”€ pino-std-serializers
β”œβ”€β”€ p-limit
β”œβ”€β”€ p-locate
β”œβ”€β”€ prelude-ls
β”œβ”€β”€ progress
β”œβ”€β”€ p-try
β”œβ”€β”€ pump
β”œβ”€β”€ punycode
β”œβ”€β”€ quick-format-unescaped
β”œβ”€β”€ randexp
β”œβ”€β”€ readable-stream
β”œβ”€β”€ recursive-readdir-sync
β”œβ”€β”€ regexpp
β”œβ”€β”€ require-directory
β”œβ”€β”€ require-main-filename
β”œβ”€β”€ resolve-from
β”œβ”€β”€ restore-cursor
β”œβ”€β”€ ret
β”œβ”€β”€ rewire
β”œβ”€β”€ rimraf
β”œβ”€β”€ run-async
β”œβ”€β”€ rxjs
β”œβ”€β”€ safe-buffer
β”œβ”€β”€ safer-buffer
β”œβ”€β”€ semver
β”œβ”€β”€ set-blocking
β”œβ”€β”€ shebang-command
β”œβ”€β”€ shebang-regex
β”œβ”€β”€ signal-exit
β”œβ”€β”€ slice-ansi
β”œβ”€β”€ sonic-boom
β”œβ”€β”€ split2
β”œβ”€β”€ sprintf-js
β”œβ”€β”€ string_decoder
β”œβ”€β”€ string.prototype.trimend
β”œβ”€β”€ string.prototype.trimleft
β”œβ”€β”€ string.prototype.trimright
β”œβ”€β”€ string.prototype.trimstart
β”œβ”€β”€ string-width
β”œβ”€β”€ strip-ansi
β”œβ”€β”€ strip-json-comments
β”œβ”€β”€ supports-color
β”œβ”€β”€ table
β”œβ”€β”€ text-table
β”œβ”€β”€ through
β”œβ”€β”€ tmp
β”œβ”€β”€ tslib
β”œβ”€β”€ type-check
β”œβ”€β”€ type-fest
β”œβ”€β”€ universalify
β”œβ”€β”€ uri-js
β”œβ”€β”€ util-deprecate
β”œβ”€β”€ v8-compile-cache
β”œβ”€β”€ validate.io-array
β”œβ”€β”€ validate.io-function
β”œβ”€β”€ validate.io-integer
β”œβ”€β”€ validate.io-integer-array
β”œβ”€β”€ validate.io-number
β”œβ”€β”€ which
β”œβ”€β”€ which-module
β”œβ”€β”€ wide-align
β”œβ”€β”€ @wikimedia
β”œβ”€β”€ word-wrap
β”œβ”€β”€ wrap-ansi
β”œβ”€β”€ wrappy
β”œβ”€β”€ write
β”œβ”€β”€ y18n
β”œβ”€β”€ yallist
β”œβ”€β”€ yargs
β”œβ”€β”€ yargs-parser
└── yargs-unparser

216 directories, 0 files

# 2️⃣ Step 2

Make a new directory for your schema lineage:

Create a new schema
$ mkdir -p jsonschema/mediawiki/desktop/button/click

And then add a current.yaml file in the directory jsonschema/mediawiki/desktop/button/click with your schema.

# 3️⃣ Step 3

Commit your change using git commit.

Below I run three commands:

  • git status – shows what files git knows about and whether those files have changed since git last saw them
  • git add – tells git that you'd like to include these files in your next commit
  • git commit – tells git that you're done working on the file. Adding -m "some message" will add a commit message to the code. Commit messages should use present tense (e.g., "Add" instead of "Added" or "Adding") and be less than 72 characters by convention.
βœ… Git commit
$ git status
On branch master
Your branch is up to date with 'origin/master'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        jsonschema/mediawiki/

nothing added to commit but untracked files present (use "git add" to track)
$ git add jsonschema/mediawiki/
$ git commit -m 'Add mediawiki/desktop/button/click'
[2021-10-28 13:17:37.619 +0000]: Looking for modified current.yaml schema files in ./jsonschema/
[2021-10-28 13:17:37.668 +0000]: Materializing /home/thcipriani/Projects/gerrit-for-product-analytics/schemas/event/secondary/jsonschema/mediawiki/desktop/button/click/current.yaml...
[2021-10-28 13:17:37.678 +0000]: Dereferencing schema with $id /mediawiki/desktop/button/click/1.0.0 using schema base URIs ./jsonschema/,https://schema.wikimedia.org/repositories/primary/jsonschema/
[2021-10-28 13:17:37.703 +0000]: Materialized schema at /home/thcipriani/Projects/gerrit-for-product-analytics/schemas/event/secondary/jsonschema/mediawiki/desktop/button/click/1.0.0.yaml.
[2021-10-28 13:17:37.704 +0000]: Materialized schema at /home/thcipriani/Projects/gerrit-for-product-analytics/schemas/event/secondary/jsonschema/mediawiki/desktop/button/click/1.0.0.json.
[2021-10-28 13:17:37.704 +0000]: Created latest symlink /home/thcipriani/Projects/gerrit-for-product-analytics/schemas/event/secondary/jsonschema/mediawiki/desktop/button/click/latest.yaml -> 1.0.0.yaml.
[2021-10-28 13:17:37.705 +0000]: Created latest symlink /home/thcipriani/Projects/gerrit-for-product-analytics/schemas/event/secondary/jsonschema/mediawiki/desktop/button/click/latest.json -> 1.0.0.json.
[2021-10-28 13:17:37.705 +0000]: Created extensionless symlink /home/thcipriani/Projects/gerrit-for-product-analytics/schemas/event/secondary/jsonschema/mediawiki/desktop/button/click/1.0.0 -> 1.0.0.yaml.
[2021-10-28 13:17:37.706 +0000]: Created latest symlink /home/thcipriani/Projects/gerrit-for-product-analytics/schemas/event/secondary/jsonschema/mediawiki/desktop/button/click/latest -> 1.0.0.yaml.
[2021-10-28 13:17:37.706 +0000]: New schema files have been materialized. Adding them to git: /home/thcipriani/Projects/gerrit-for-product-analytics/schemas/event/secondary/jsonschema/mediawiki/desktop/button/click/1.0.0.yaml,/home/thcipriani/Projects/gerrit-for-product-analytics/schemas/event/secondary/jsonschema/mediawiki/desktop/button/click/latest.yaml,/home/thcipriani/Projects/gerrit-for-product-analytics/schemas/event/secondary/jsonschema/mediawiki/desktop/button/click/1.0.0,/home/thcipriani/Projects/gerrit-for-product-analytics/schemas/event/secondary/jsonschema/mediawiki/desktop/button/click/latest,/home/thcipriani/Projects/gerrit-for-product-analytics/schemas/event/secondary/jsonschema/mediawiki/desktop/button/click/1.0.0.json,/home/thcipriani/Projects/gerrit-for-product-analytics/schemas/event/secondary/jsonschema/mediawiki/desktop/button/click/latest.json
[master 46e19bc] Add mediawiki/desktop/button/click
 7 files changed, 132 insertions(+)
 create mode 120000 jsonschema/mediawiki/desktop/button/click/1.0.0
 create mode 100644 jsonschema/mediawiki/desktop/button/click/1.0.0.json
 create mode 100644 jsonschema/mediawiki/desktop/button/click/1.0.0.yaml
 create mode 100644 jsonschema/mediawiki/desktop/button/click/current.yaml
 create mode 120000 jsonschema/mediawiki/desktop/button/click/latest
 create mode 120000 jsonschema/mediawiki/desktop/button/click/latest.json
 create mode 120000 jsonschema/mediawiki/desktop/button/click/latest.yaml

You'll notice that a lot of things happened after you typed git commit. Git used a script to create version files for your new schema lineage. You can see them in your directory tree:

jsonschema/mediawiki/desktop/button/click/
β”œβ”€β”€ 1.0.0 -> 1.0.0.yaml
β”œβ”€β”€ 1.0.0.json
β”œβ”€β”€ 1.0.0.yaml
β”œβ”€β”€ current.yaml
β”œβ”€β”€ latest -> 1.0.0.yaml
β”œβ”€β”€ latest.json -> 1.0.0.json
└── latest.yaml -> 1.0.0.yaml