aboutsummaryrefslogblamecommitdiff
path: root/po/pt/LC_MESSAGES/_tils/2020-11-30-storing-ci-data-on-git-notes.po
blob: e9cc227159405c42ab148163a6bbda62dcb8c7b8 (plain) (tree)
























































































































                                                                                                
                                                                                                                                                                    









                                                                                                 

                                                                                 



                                                                
                                                                                                                                                                




                                                                             
                             
         


                             
#
msgid ""
msgstr ""

msgid "title: Storing CI data on Git notes"
msgstr ""

msgid "date: 2020-11-30"
msgstr ""

msgid "layout: post"
msgstr ""

msgid "lang: en"
msgstr ""

msgid "ref: storing-ci-data-on-git-notes"
msgstr ""

msgid ""
"Extending the bare bones CI server I've [talked about before][previous-"
"article], divoplade on Freenode suggested storing CI artifacts on [Git "
"notes][git-notes], such as tarballs, binaries, logs, *etc*."
msgstr ""

msgid ""
"I've written a small script that will put log files and CI job data on Git "
"notes, and make it visible on the porcelain log. It is a simple extension of"
" the previous article:"
msgstr ""

msgid ""
"#!/usr/bin/env bash\n"
"set -Eeuo pipefail\n"
"set -x\n"
"\n"
"PREFIX='/srv/ci/vps'\n"
"mkdir -p \"$PREFIX\"\n"
"read -r _ SHA _ # oldrev newrev refname\n"
"FILENAME=\"$(date -Is)-$SHA.log\"\n"
"LOGFILE=\"$PREFIX/$FILENAME\"\n"
"exec &> >(tee -a \"$LOGFILE\")\n"
"\n"
"echo \"Starting CI job at: $(date -Is)\"\n"
"\n"
"finish() {\n"
"  STATUS=\"$?\"\n"
"  printf \"\\n\\n>>> exit status was %s\\n\" \"$STATUS\"\n"
"  echo \"Finishing CI job at: $(date -Is)\"\n"
"  popd\n"
"  NOTE=$(cat <<EOF\n"
"See CI logs with:\n"
"  git notes --ref=refs/notes/ci-logs show $SHA\n"
"  git notes --ref=refs/notes/ci-data show $SHA\n"
"EOF\n"
")\n"
"  git notes --ref=refs/notes/ci-data add -f -m \"$STATUS $FILENAME\"\n"
"  git notes --ref=refs/notes/ci-logs add -f -F \"$LOGFILE\"\n"
"  git notes add -f -m \"$NOTE\"\n"
"  printf \"\\n\\n>>> CI logs added as Git note.\"\n"
"}\n"
"trap finish EXIT\n"
"\n"
"unset GIT_DIR\n"
"CLONE=\"$(mktemp -d)\"\n"
"git clone . \"$CLONE\"\n"
"pushd \"$CLONE\"\n"
"git config --global user.email git@euandre.org\n"
"git config --global user.name 'EuAndreh CI'\n"
"\n"
"./container make check site\n"
"./container make publish\n"
msgstr ""

msgid "The important part is in the `finish()` function:"
msgstr ""

msgid ""
"#25 stores the exit status and the generated filename separated by spaces;"
msgstr ""

msgid "#26 adds the log file in a note using the `refs/notes/ci-logs` ref;"
msgstr ""

msgid "#27 it adds a note to the commit saying how to see the logs."
msgstr ""

msgid ""
"A commit now has an attached note, and shows it whenever you look at it:"
msgstr ""

msgid ""
"$ git show 930ba1888f49f11e52a4a715438cd9f5f413dd9c\n"
"commit 930ba1888f49f11e52a4a715438cd9f5f413dd9c (oldvps/master)\n"
"Author: EuAndreh <eu@euandre.org>\n"
"Date:   Mon Nov 30 01:11:38 2020 -0300\n"
"\n"
"    vps.scm: Uncomment mcron job time marker\n"
"\n"
"Notes:\n"
"    See CI logs with:\n"
"      git notes --ref=refs/notes/ci-logs show 930ba1888f49f11e52a4a715438cd9f5f413dd9c\n"
"      git notes --ref=refs/notes/ci-data show 930ba1888f49f11e52a4a715438cd9f5f413dd9c\n"
"\n"
"diff --git a/sync/vps.scm b/sync/vps.scm\n"
"index 3f6ca69..02b9cc6 100644\n"
"--- a/sync/vps.scm\n"
"+++ b/sync/vps.scm\n"
"@@ -280,7 +280,7 @@ pki \" mail-domain \" key  \\\"\" (tls-priv-for mail-domain) \"\\\"\")))\n"
"              tls-prefixes)))\n"
"\n"
" (define generate-ci-index-html-job\n"
"-  #~(job \"* * * * *\" ;; \"*/5 * * * *\"\n"
"+  #~(job \"*/5 * * * *\"\n"
"          #$(program-file\n"
"             \"generate-ci-index-html.scm\"\n"
"             (with-imported-modules (modules:source-module-closure\n"
msgstr ""

msgid ""
"Other tools such as [cgit][cgit] will also show notes on the web interface: "
"[https://euandreh.xyz/vps.git/commit?id=930ba1888f49f11e52a4a715438cd9f5f413dd9c](https://euandreh.xyz/vps.git/commit?id=930ba1888f49f11e52a4a715438cd9f5f413dd9c)"
msgstr ""

msgid ""
"You can go even further: since cgit can serve raw blob directly, you can "
"even serve such artifacts (log files, release artifacts, binaries) from cgit"
" itself:"
msgstr ""

msgid ""
"$ SHA=\"$(git notes --ref=refs/notes/ci-logs list 930ba1888f49f11e52a4a715438cd9f5f413dd9c)\"\n"
"$ echo \"https://euandreh.xyz/vps.git/blob?id=$SHA\"\n"
"https://euandreh.xyz/vps.git/blob?id=b3a6438a0c7a47864c54c61359b6ef50e864dbff\n"
msgstr ""

msgid ""
"And like that you'll have cgit serving the artifacts for you: "
"[https://euandreh.xyz/vps.git/blob?id=b3a6438a0c7a47864c54c61359b6ef50e864dbff](https://euandreh.xyz/vps.git/blob?id=b3a6438a0c7a47864c54c61359b6ef50e864dbff)"
msgstr ""

msgid ""
"[previous-article]: {% link _tils/2020-11-12-diy-bare-bones-ci-server-with-"
"bash-and-nix.md %} [git-notes]: https://git-scm.com/docs/git-notes [cgit]: "
"https://git.zx2c4.com/cgit/"
msgstr ""

msgid "eu_categories: git,ci"
msgstr ""