Skip to content

Commit d38ff08

Browse files
authored
feat: github actions #440 (#444)
feat: add github actions yaml file that uses a custom made docker image to build the code and run the unit tests #440
1 parent 1608219 commit d38ff08

File tree

3 files changed

+88
-0
lines changed

3 files changed

+88
-0
lines changed

.github/workflows/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Workflows
2+
This page contains some documentation on the workflows for this repository.
3+
4+
## build_test
5+
The workflow build_test is used to build and test the code (see build_test.yaml). We are using a custom docker image for building and testing the code. You can find the image on our [Docker Hub](https://hub.docker.com/repository/docker/threefolddev/tfchain). The dockerfile build_test.Dockerfile was used to build that image. If the image no longer meets the expectations please follow these steps:
6+
7+
1) Update the dockerfile as required (add what you need)
8+
2) Build the new image (execute the comment with .github/workflows as working directory and make sure to increment the version):
9+
> docker build -t threefolddev/tfchain:\<VERSION> -f build_test.Dockerfile .
10+
3) Make sure to test the pipeline manually using the docker image that you build
11+
> docker run --it -rm threefolddev/tfchain:\<VERSION> \
12+
> // clone the repository, build and test tfchain
13+
4) Upload the image (you will need the credentials):
14+
> docker login
15+
> docker push threefolddev/tfchain:\<VERSION>
16+
5) Update the pipeline on the repository https://github.com/threefoldtech/tfchain under .github/workflows to use this new image
17+
6) Push your changes, create a PR and let the pipeline run. If it fails due to changes to the image you should start over the steps.
18+
7) Once the PR is landed please tag the repository so that we can trace back the dockerfile given the version:
19+
> git tag -a dockerfile-build-v\<VERSION> -m "new dockerfile version \<VERSION>"
20+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
FROM ubuntu:20.04
2+
ENV DEBIAN_FRONTEND=noninteractive
3+
COPY clean_disk_space.sh clean_disk_space.sh
4+
RUN apt-get update && \
5+
apt-get install -y \
6+
build-essential \
7+
clang \
8+
cmake \
9+
curl \
10+
git \
11+
librocksdb-dev \
12+
libclang-dev \
13+
lld \
14+
lldb \
15+
python3 \
16+
python3-pip \
17+
tar \
18+
zstd && \
19+
curl https://sh.rustup.rs -sSf | sh -s -- -y && \
20+
$HOME/.cargo/bin/rustup install nightly-2022-05-11 && \
21+
# cleanup image
22+
rm -rf /var/lib/apt/lists/* && \
23+
apt-get clean && \
24+
apt-get autoclean && \
25+
apt-get autoremove && \
26+
rm -rf /tmp/*
27+
RUN /bin/bash

.github/workflows/build_test.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Build and Test
2+
on:
3+
push:
4+
branches:
5+
- development
6+
pull_request:
7+
jobs:
8+
build-and-test:
9+
runs-on: [self-hosted, poc]
10+
container:
11+
image: threefolddev/tfchain:0
12+
env:
13+
DEBIAN_FRONTEND: noninteractive
14+
steps:
15+
- uses: actions/checkout@v3
16+
17+
- name: Cache build
18+
uses: actions/cache@v3
19+
with:
20+
path: |
21+
~/.cargo/bin/
22+
~/.cargo/registry/index/
23+
~/.cargo/registry/cache/
24+
~/.cargo/git/db/
25+
substrate-node/target/
26+
key: ${{ runner.os }}-tfchain-cargo-${{ hashFiles('**/Cargo.lock') }}
27+
restore-keys: ${{ runner.os }}-tfchain-cargo-
28+
29+
30+
- name: Build
31+
run: |
32+
cd substrate-node
33+
$HOME/.cargo/bin/rustup target add wasm32-unknown-unknown --toolchain nightly-2022-05-11
34+
$HOME/.cargo/bin/cargo +nightly-2022-05-11 build --release
35+
36+
- name: Unit tests
37+
run: |
38+
cd substrate-node
39+
$HOME/.cargo/bin/cargo +nightly-2022-05-11 test --no-fail-fast
40+
cd pallets
41+
$HOME/.cargo/bin/cargo +nightly-2022-05-11 test --no-fail-fast

0 commit comments

Comments
 (0)