Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
name: GitHub Pages
name: Build Stats

on:
push:
branches:
- main
pull_request:
workflow_dispatch:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For testing workflow in branches other than main.

schedule:
# run every Sunday at 22:12 UTC
- cron: '12 22 * * 0'
Expand All @@ -13,12 +14,11 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/checkout@v2
with:
repository: mozilla/gecko-dev
path: gecko-dev
- name: Clone `gecko-dev`
run: |
git clone https://github.com/mozilla/gecko-dev.git

- run: npm install -g mustache

Expand All @@ -29,6 +29,10 @@ jobs:
cat build/data.json
mustache build/data.json index.mustache > build/index.html
cat build/index.html

- name: Gather commits by day and file extension statistics
run: |
./01stats.sh gecko-dev build
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do we get out of this build step? Also I see that it takes pretty long time to complete.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The goal is to move stats collection commands out of GitHub Actions YAML, so that they could be run standalone.

As I continued experiments in my main branch after opening this PR, more things started to creep in. The command that takes the most time is git fetch --unshallow added in the last commit to start playing with historical data.


- name: Deploy
uses: JamesIves/[email protected]
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
gecko-dev/
21 changes: 21 additions & 0 deletions 01stats.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

REPODIR=${1:-.} # default to . if first argument is not set
SCRIPTDIR=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
BUILDDIR=$(readlink -f "${2:-$SCRIPTDIR}")

[[ -d $BUILDDIR ]] || { echo "$BUILDDIR dir does not exist"; exit 1; }

(cd "$REPODIR" || exit

if $(git rev-parse --is-shallow-repository); then
echo "WARNING: Repository checkout is shallow. Data is incomplete."
fi

echo "writing $BUILDDIR/commits-per-day.txt"
git log --date=short --format="%cd" --reverse --topo-order |
uniq -c > "$BUILDDIR"/commits-per-day.txt

echo "writing $BUILDDIR/extensions.txt"
"$SCRIPTDIR"/dev/git-file-stats > "$BUILDDIR/extensions.txt"
)
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# firefox-lang-stats

How much Rust in Firefox? You can see the chart [here][gh-pages].
How much Rust in Firefox? See [the chart].

Repository contains scripts collecting the language statistics for
[mozilla/gecko-dev] repository. Gathered data then assembled into a pie chart
`index.mustache`.

Page is updated weekly with a Travis Cron job. See the `date` meta tag for
the exact build time.
Repository contains scripts collecting language statistics for
[mozilla/gecko-dev] repository. The data is saved as JSON in
[gh-pages] branch along with a pie chart, which is rendered from
`index.mustache` template. The GitHub Pages is updated by weekly
CI job, with the build time recorded in `date` meta tag.

# Build

Expand All @@ -25,4 +24,5 @@ mustache data.json index.mustache > index.html


[mozilla/gecko-dev]: https://github.com/mozilla/gecko-dev
[gh-pages]: https://4e6.github.io/firefox-lang-stats/
[the chart]: https://4e6.github.io/firefox-lang-stats/
[gh-pages]: https://github.com/4e6/firefox-lang-stats/tree/gh-pages
2 changes: 1 addition & 1 deletion dev/build-data
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ echo_data_footer()
# print a row for a diagram
echo_data_line()
{
echo "{\"name\":\"$1\", \"loc\":$2}$3"
echo " {\"name\":\"$1\", \"loc\":$2}$3"
}

echo_meta_date()
Expand Down
9 changes: 5 additions & 4 deletions dev/git-file-stats
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
# 54 xml
# 106 xsd

git ls-files | # list files
xargs -n 1 -i sh -c 'v="{}"; echo "${v##*.}"' | # get extensions
sort | uniq -c | # group
sort -n -k 1 # sort by first column
git ls-files | # list files
grep -Po "(?<=\.)\w+$" | # match strings and show only matched lines
sort | # sort before counting to avoid group splits
uniq -c | # count unique
sort -n -k 1 # sort naturally by count (first column)
Loading