summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorflywind <43030857+xflywind@users.noreply.github.com>2022-07-11 23:27:01 +0800
committerGitHub <noreply@github.com>2022-07-11 23:27:01 +0800
commitcf1c14936670ef0c175149f6fba4dffc1cf4ba43 (patch)
treec382725f9a1db388a03e7c36468a59121e72724a
parentfb5fbf1e087563f0288b8ed684c8dcc1891730b0 (diff)
downloadNim-cf1c14936670ef0c175149f6fba4dffc1cf4ba43.tar.gz
tracking the memory usage of orc-booting compiler for each commit (#19941)
* yaml

* pub

* redo

* let's comment

* now action

* newly

* code name

* build

* ready

* remove submodule

* build

* modify name

* fix

* rephrase

* trigger when PR is merged
-rw-r--r--.github/workflows/ci_publish.yml90
-rw-r--r--ci/action.nim28
2 files changed, 118 insertions, 0 deletions
diff --git a/.github/workflows/ci_publish.yml b/.github/workflows/ci_publish.yml
new file mode 100644
index 000000000..94ea5ff8f
--- /dev/null
+++ b/.github/workflows/ci_publish.yml
@@ -0,0 +1,90 @@
+name: Tracking orc-booting compiler memory usage
+
+on:
+  push:
+    branches:
+      - devel
+
+
+jobs:
+  build:
+    strategy:
+      fail-fast: false
+      matrix:
+        os: [ubuntu-20.04]
+        cpu: [amd64]
+    name: '${{ matrix.os }}'
+    runs-on: ${{ matrix.os }}
+    steps:
+      - name: 'Checkout'
+        uses: actions/checkout@v2
+        with:
+          fetch-depth: 2
+
+      - name: 'Install node.js 16.x'
+        uses: actions/setup-node@v2
+        with:
+          node-version: '16.x'
+
+      - name: 'Install dependencies (Linux amd64)'
+        if: runner.os == 'Linux' && matrix.cpu == 'amd64'
+        run: |
+          sudo apt-fast update -qq
+          DEBIAN_FRONTEND='noninteractive' \
+            sudo apt-fast install --no-install-recommends -yq \
+              libcurl4-openssl-dev libgc-dev libsdl1.2-dev libsfml-dev \
+              valgrind libc6-dbg libblas-dev xorg-dev
+      - name: 'Install dependencies (macOS)'
+        if: runner.os == 'macOS'
+        run: brew install boehmgc make sfml gtk+3
+      - name: 'Install dependencies (Windows)'
+        if: runner.os == 'Windows'
+        shell: bash
+        run: |
+          set -e
+          . ci/funs.sh
+          nimInternalInstallDepsWindows
+          echo_run echo "${{ github.workspace }}/dist/mingw64/bin" >> "${GITHUB_PATH}"
+
+      - name: 'Add build binaries to PATH'
+        shell: bash
+        run: echo "${{ github.workspace }}/bin" >> "${GITHUB_PATH}"
+
+      - name: 'System information'
+        shell: bash
+        run: . ci/funs.sh && nimCiSystemInfo
+
+      - name: 'Build csourcesAny'
+        shell: bash
+        run: . ci/funs.sh && nimBuildCsourcesIfNeeded CC=gcc ucpu='${{ matrix.cpu }}'
+
+      - name: 'Build koch'
+        shell: bash
+        run: nim c koch
+
+      - name: 'Build Nim'
+        shell: bash
+        run: ./koch boot -d:release -d:nimStrictMode --lib:lib
+
+      - name: 'Action'
+        shell: bash
+        run: nim c -r -d:release ci/action.nim
+
+      - name: 'Comment'
+        uses: actions/github-script@v6
+        with:
+          script: |
+            const fs = require('fs');
+
+            try {
+              const data = fs.readFileSync('ci/nimcache/results.txt', 'utf8');
+              github.rest.issues.createComment({
+              issue_number: context.issue.number,
+              owner: context.repo.owner,
+              repo: context.repo.repo,
+              body: data
+            })
+            } catch (err) {
+              console.error(err);
+            }
+
diff --git a/ci/action.nim b/ci/action.nim
new file mode 100644
index 000000000..8c3260096
--- /dev/null
+++ b/ci/action.nim
@@ -0,0 +1,28 @@
+import std/[strutils, os, osproc, parseutils, strformat]
+
+
+proc main() =
+  var msg = ""
+  const cmd = "./koch boot --gc:orc -d:release"
+
+  let (output, exitCode) = execCmdEx(cmd)
+
+  doAssert exitCode == 0, output
+
+  var start = rfind(output, "Hint: gc")
+  if start < 0:
+    start = rfind(output, "Hint: mm")
+  doAssert parseUntil(output, msg, "; proj", start) > 0, output
+
+  let (commitHash, _) = execCmdEx("""git log --format="%H" -n 1""")
+
+  let welcomeMessage = fmt"""Thanks for your hard work on this PR!
+The lines below are statistics of the Nim compiler built from {commitHash}
+
+{msg}
+"""
+  createDir "ci/nimcache"
+  writeFile "ci/nimcache/results.txt", welcomeMessage
+
+when isMainModule:
+  main()
\ No newline at end of file