Skip to content

Commit

Permalink
A number of CI improvements
Browse files Browse the repository at this point in the history
- Adopted a number of QOL improvements from littlefs
- Split testing and profiling into separate jobs
- Added status updates which includes changes for both code size and runtime
- Increased timeouts in tests by 10x. This is an effor to avoid false
  failures which occur often if your machine does not handle timeouts
  quickly enough.

  Note, this does increase the time to run tests by, roughly, 10x

  Realistically this is a hack, the correct solution is to stub out the
  timing code for testing so that we can control the number of ticks
  that pass exactly.
  • Loading branch information
geky committed Aug 4, 2019
1 parent 101f830 commit e3008b2
Show file tree
Hide file tree
Showing 3 changed files with 219 additions and 124 deletions.
126 changes: 111 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,111 @@
script:
# Strict compilation of library
- CFLAGS='-pedantic -Werror' make

# Runtime tests
- make test

# Relative profiling with current master
- if ( git clone https://github.com/geky/events tests/master &&
make -s -C tests/master prof | tee tests/results.txt ) ;
then
cat tests/results.txt | make prof ;
else
make prof ;
fi
# Environment variables
env:
global:
- CFLAGS=-Werror

# CI jobs
jobs:
include:
# Test stage
- stage: test
env:
- STAGE=test
- NAME=test
script:
# Strict compilation of library only (tests use gcc features)
- make CFLAGS+=-pedantic
# Run tests
- make test
# Find code size with smallest configuration
- make clean size OBJ=equeue.o | tee sizes

# Update status with code size, compare with master if possible
- |
if [ "$TRAVIS_TEST_RESULT" -eq 0 ]
then
CURR=$(tail -n1 sizes | awk '{print $1}')
PREV=$(curl -u "$GEKY_BOT_STATUSES" https://api.github.com/repos/$TRAVIS_REPO_SLUG/status/master \
| jq -re "select(.sha != \"$TRAVIS_COMMIT\")
| .statuses[] | select(.context == \"$STAGE/$NAME\").description
| capture(\"code size is (?<size>[0-9]+)\").size" \
|| echo 0)
STATUS="Passed, code size is ${CURR}B"
if [ "$PREV" -ne 0 ]
then
STATUS="$STATUS ($(python -c "print '%+.2f' % (100*($CURR-$PREV)/$PREV.0)")%)"
fi
fi
# Runtime profiling stage
- stage: test
env:
- STAGE=test
- NAME=prof
script:
# Relative profiling against master
- if ( git clone https://github.com/geky/equeue master &&
make -s -C master prof | tee master/runtime ) ;
then
cat master/runtime | make prof | tee runtime ;
else
make prof | tee runtime ;
fi

# Update status with profile results, compare with master if possible
- |
if [ "$TRAVIS_TEST_RESULT" -eq 0 ]
then
CURR=$(grep -o '[0-9]\+ cycles' runtime | \
awk '{sum += $1} END {print sum}')
PREV=$(curl -u "$GEKY_BOT_STATUSES" https://api.github.com/repos/$TRAVIS_REPO_SLUG/status/master \
| jq -re "select(.sha != \"$TRAVIS_COMMIT\")
| .statuses[] | select(.context == \"$STAGE/$NAME\").description
| capture(\"runtime is (?<runtime>[0-9]+)\").runtime" \
|| echo 0)
STATUS="Passed, runtime is ${CURR} cycles"
if [ "$PREV" -ne 0 ]
then
STATUS="$STATUS ($(python -c "print '%+.2f' % (100*($CURR-$PREV)/$PREV.0)")%)"
fi
fi
# Manage statuses
before_install:
- |
curl -u "$GEKY_BOT_STATUSES" -X POST \
https://api.github.com/repos/$TRAVIS_REPO_SLUG/statuses/${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT} \
-d "{
\"context\": \"$STAGE/$NAME\",
\"state\": \"pending\",
\"description\": \"${STATUS:-In progress}\",
\"target_url\": \"https://travis-ci.org/$TRAVIS_REPO_SLUG/jobs/$TRAVIS_JOB_ID\"
}"
after_failure:
- |
curl -u "$GEKY_BOT_STATUSES" -X POST \
https://api.github.com/repos/$TRAVIS_REPO_SLUG/statuses/${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT} \
-d "{
\"context\": \"$STAGE/$NAME\",
\"state\": \"failure\",
\"description\": \"${STATUS:-Failed}\",
\"target_url\": \"https://travis-ci.org/$TRAVIS_REPO_SLUG/jobs/$TRAVIS_JOB_ID\"
}"
after_success:
- |
curl -u "$GEKY_BOT_STATUSES" -X POST \
https://api.github.com/repos/$TRAVIS_REPO_SLUG/statuses/${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT} \
-d "{
\"context\": \"$STAGE/$NAME\",
\"state\": \"success\",
\"description\": \"${STATUS:-Passed}\",
\"target_url\": \"https://travis-ci.org/$TRAVIS_REPO_SLUG/jobs/$TRAVIS_JOB_ID\"
}"
# Job control
stages:
- name: test
22 changes: 11 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
TARGET = libequeue.a

CC = gcc
AR = ar
SIZE = size
CC ?= gcc
AR ?= ar
SIZE ?= size

SRC += $(wildcard *.c)
OBJ := $(SRC:.c=.o)
DEP := $(SRC:.c=.d)
ASM := $(SRC:.c=.s)

ifdef DEBUG
CFLAGS += -O0 -g3
override CFLAGS += -O0 -g3
else
CFLAGS += -O2
override CFLAGS += -Os
endif
ifdef WORD
CFLAGS += -m$(WORD)
override CFLAGS += -m$(WORD)
endif
CFLAGS += -I.
CFLAGS += -std=c99
CFLAGS += -Wall
CFLAGS += -D_XOPEN_SOURCE=600
override CFLAGS += -I.
override CFLAGS += -std=c99
override CFLAGS += -Wall
override CFLAGS += -D_XOPEN_SOURCE=600

LFLAGS += -pthread
override LFLAGS += -pthread


all: $(TARGET)
Expand Down
Loading

0 comments on commit e3008b2

Please sign in to comment.