Skip to content

Commit

Permalink
Merge pull request #3 from rmg/actions-workflow
Browse files Browse the repository at this point in the history
Add workflow for basic CI
  • Loading branch information
rmg authored Jun 29, 2023
2 parents 23cd229 + 43ed3eb commit adb7dfc
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 19 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/makefile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: build & test

on:
pull_request:
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
id: cache
with:
key: shared
path: raw.tar
- if: steps.cache.outputs.cache-hit != 'true'
run: make raw.tar
- name: build & install
run: |
sudo apt-get update
sudo apt-get install ripgrep
make scan-c scan-go scan-rs
{
printf "## Versions\n"
grep -V
rg -V
node --version
rustc --version
go version
cc --version
} >> "$GITHUB_STEP_SUMMARY"
- name: make c.txt
run: |
printf '### c\n' >> "$GITHUB_STEP_SUMMARY"
make c.txt TIME_REPORT=$GITHUB_STEP_SUMMARY
- name: make go.txt
run: |
printf '### go\n' >> "$GITHUB_STEP_SUMMARY"
make go.txt TIME_REPORT=$GITHUB_STEP_SUMMARY
- name: make rs.txt
run: |
printf '### rs\n' >> "$GITHUB_STEP_SUMMARY"
make rs.txt TIME_REPORT=$GITHUB_STEP_SUMMARY
- name: make grep.txt
run: |
printf '### grep\n' >> "$GITHUB_STEP_SUMMARY"
make grep.txt TIME_REPORT=$GITHUB_STEP_SUMMARY
- name: make ripgrep.txt
run: |
printf '### ripgrep\n' >> "$GITHUB_STEP_SUMMARY"
make ripgrep.txt TIME_REPORT=$GITHUB_STEP_SUMMARY
- name: make js.txt
run: |
printf '### js\n' >> "$GITHUB_STEP_SUMMARY"
make js.txt TIME_REPORT=$GITHUB_STEP_SUMMARY
43 changes: 24 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ CFLAGS := -Werror -Wall
FAST_CFLAGS := $(CFLAGS) -O3 -DNDEBUG
DEBUG_CFLAGS := $(CFLAGS) -g
SIMD_CFLAGS := $(CFLAGS) -DUSE_SIMD=1
TIME_CMD := command time -p

ifdef TIME_REPORT
TIME_CMD := $(TIME_CMD) -a -o $(TIME_REPORT)
endif

hexgrep scan-c-fast: main.c
$(CC) $(FAST_CFLAGS) -o $@ $<
Expand Down Expand Up @@ -44,19 +49,19 @@ main.s: main.c
$(CC) $(CFLAGS) -O3 -DNDEBUG -S -mllvm --x86-asm-syntax=intel -o $@ $<

time-simd: scan-c-fast-simd
time ./scan-c-fast-simd < raw.tar > c.txt
$(TIME_CMD) ./scan-c-fast-simd < raw.tar > c.txt
diff -q c.txt prev.txt || diff c.txt prev.txt | wc -l

time: scan-c-fast
time ./scan-c-fast < raw.tar > c.txt
$(TIME_CMD) ./scan-c-fast < raw.tar > c.txt
diff -q c.txt prev.txt || diff c.txt prev.txt | wc -l

counts: scan-c-counters
time ./scan-c-counters < raw.tar > c.txt
$(TIME_CMD) ./scan-c-counters < raw.tar > c.txt
diff -q c.txt prev.txt || diff c.txt prev.txt | wc -l

test: scan-c-debug
time ./scan-c-debug < raw.tar > c.txt
$(TIME_CMD) ./scan-c-debug < raw.tar > c.txt
diff -q c.txt prev.txt || diff c.txt prev.txt | wc -l

debug: scan-c-debug
Expand All @@ -69,30 +74,30 @@ scan-rs: main.rs
rustc -O -o $@ $<

%.txt: scan-% $(SAMPLE)
time ./scan-$* < $(SAMPLE) > $@
time ./scan-$* < $(SAMPLE) > $@
time ./scan-$* < $(SAMPLE) > $@
$(TIME_CMD) ./scan-$* < $(SAMPLE) > $@
$(TIME_CMD) ./scan-$* < $(SAMPLE) > $@
$(TIME_CMD) ./scan-$* < $(SAMPLE) > $@

js.txt: main.js $(SAMPLE)
time node main.js < $(SAMPLE) > $@
time node main.js < $(SAMPLE) > $@
time node main.js < $(SAMPLE) > $@
$(TIME_CMD) node main.js < $(SAMPLE) > $@
$(TIME_CMD) node main.js < $(SAMPLE) > $@
$(TIME_CMD) node main.js < $(SAMPLE) > $@

grep.txt: $(SAMPLE)
time grep -E -a -o '[0-9a-f]{40}' < $(SAMPLE) > $@ || true
time grep -E -a -o '[0-9a-f]{40}' < $(SAMPLE) > $@ || true
time grep -E -a -o '[0-9a-f]{40}' < $(SAMPLE) > $@ || true
$(TIME_CMD) grep -E -a -o '[0-9a-f]{40}' < $(SAMPLE) > $@ || true
$(TIME_CMD) grep -E -a -o '[0-9a-f]{40}' < $(SAMPLE) > $@ || true
$(TIME_CMD) grep -E -a -o '[0-9a-f]{40}' < $(SAMPLE) > $@ || true

ripgrep.txt: $(SAMPLE)
time rg -o -a '[a-f0-9]{40}' < $(SAMPLE) > $@ || true
time rg -o -a '[a-f0-9]{40}' < $(SAMPLE) > $@ || true
time rg -o -a '[a-f0-9]{40}' < $(SAMPLE) > $@ || true
$(TIME_CMD) rg -o -a '[a-f0-9]{40}' < $(SAMPLE) > $@ || true
$(TIME_CMD) rg -o -a '[a-f0-9]{40}' < $(SAMPLE) > $@ || true
$(TIME_CMD) rg -o -a '[a-f0-9]{40}' < $(SAMPLE) > $@ || true

docker.txt: $(SAMPLE)
docker build -t hexgrep:local .
time docker run --volume $(abspath ${SAMPLE}):/sample --rm -i hexgrep:local sample > $@ || true
time docker run --volume $(abspath ${SAMPLE}):/sample --rm -i hexgrep:local sample > $@ || true
time docker run --volume $(abspath ${SAMPLE}):/sample --rm -i hexgrep:local sample > $@ || true
$(TIME_CMD) docker run --volume $(abspath ${SAMPLE}):/sample --rm -i hexgrep:local sample > $@ || true
$(TIME_CMD) docker run --volume $(abspath ${SAMPLE}):/sample --rm -i hexgrep:local sample > $@ || true
$(TIME_CMD) docker run --volume $(abspath ${SAMPLE}):/sample --rm -i hexgrep:local sample > $@ || true

raw.tar:
docker pull node:latest
Expand Down

0 comments on commit adb7dfc

Please sign in to comment.