Skip to content

Commit

Permalink
Reimplement CI on the base of Github Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
evilaliv3 committed Dec 7, 2023
1 parent 1437737 commit b5241f6
Show file tree
Hide file tree
Showing 9 changed files with 155 additions and 142 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Build

on:
push:
branches: [ main, devel, github-workflows]
pull_request:
branches: [ main, devel ]

jobs:
run_build:
runs-on: "ubuntu-latest"
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install git
run: |
sudo apt-get update -q
sudo apt-get install -y git
- name: Run tests
run: |
cd $GITHUB_WORKSPACE
./.github/workflows/scripts/run-build.sh
File renamed without changes.
41 changes: 41 additions & 0 deletions .github/workflows/scripts/run-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

set -e

LOGFILE="/var/globaleaks/log/globaleaks.log"
ACCESSLOG="/var/globaleaks/log/access.log"

function atexit {
if [[ -f $LOGFILE ]]; then
cat $LOGFILE
fi

if [[ -f $ACCESSLOG ]]; then
cat $ACCESSLOG
fi
}

trap atexit EXIT

sudo apt-get install -y debootstrap

export chroot="/tmp/globaleaks_chroot/"
sudo mkdir -p "$chroot/build"
sudo cp -R $GITHUB_WORKSPACE/ "$chroot/build"
export LC_ALL=en_US.utf8
export DEBIAN_FRONTEND=noninteractive
sudo -E ls "$chroot/build" -al
sudo -E debootstrap --arch=amd64 bookworm "$chroot" http://deb.debian.org/debian/
sudo -E su -c 'echo "deb http://deb.debian.org/debian bookworm main contrib" > /tmp/globaleaks_chroot/etc/apt/sources.list'
sudo -E su -c 'echo "deb http://deb.debian.org/debian bookworm main contrib" >> /tmp/globaleaks_chroot/etc/apt/sources.list'
sudo -E mount --rbind /proc "$chroot/proc"
sudo -E mount --rbind /sys "$chroot/sys"
sudo -E chroot "$chroot" apt-get update -y
sudo -E chroot "$chroot" apt-get upgrade -y
sudo -E chroot "$chroot" apt-get install -y lsb-release locales sudo
sudo -E su -c 'echo "en_US.UTF-8 UTF-8" >> /tmp/globaleaks_chroot/etc/locale.gen'
sudo -E chroot "$chroot" locale-gen
sudo -E chroot "$chroot" useradd -m builduser
sudo -E su -c 'echo "builduser ALL=NOPASSWD: ALL" >> "$chroot"/etc/sudoers'
sudo -E chroot "$chroot" chown builduser -R /build
sudo -E chroot "$chroot" su - builduser /bin/bash -c '/build/GlobaLeaks/.github/workflows/scripts/build_and_install.sh'
55 changes: 55 additions & 0 deletions .github/workflows/scripts/run-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash

set -e

LOGFILE="$GITHUB_WORKSPACE/backend/workingdir/log/globaleaks.log"
ACCESSLOG="$GITHUB_WORKSPACE/backend/workingdir/log/access.log"

function atexit {
if [[ -f $LOGFILE ]]; then
cat $LOGFILE
fi

if [[ -f $ACCESSLOG ]]; then
cat $ACCESSLOG
fi
}

trap atexit EXIT

setupClientDependencies() {
cd $GITHUB_WORKSPACE/client # to install frontend dependencies
npm install
grunt instrument-client
}

setupBackendDependencies() {
cd $GITHUB_WORKSPACE/backend # to install backend dependencies
pip3 install -r requirements/requirements-$(lsb_release -cs).txt
}

setupDependencies() {
setupClientDependencies
setupBackendDependencies
}

sudo apt-get update
sudo apt-get install -y tor
npm install -g grunt grunt-cli

pip install coverage

echo "Running backend unit tests"
setupDependencies
cd $GITHUB_WORKSPACE/backend && coverage run setup.py test

$GITHUB_WORKSPACE/backend/bin/globaleaks -z
sleep 5

echo "Running BrowserTesting locally collecting code coverage"
cd $GITHUB_WORKSPACE/client && npm test

cd $GITHUB_WORKSPACE/backend && coverage xml
bash <(curl -Ls https://coverage.codacy.com/get.sh) report -l Python -r $GITHUB_WORKSPACE/backend/coverage.xml
bash <(curl -Ls https://coverage.codacy.com/get.sh) report -l Javascript -r $GITHUB_WORKSPACE/client/cypress/coverage/lcov.info
bash <(curl -Ls https://coverage.codacy.com/get.sh) final
29 changes: 29 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Test

on:
push:
branches: [ main, devel, github-workflows]
pull_request:
branches: [ main, devel ]

env:
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}

jobs:
run_tests:
runs-on: "ubuntu-latest"
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install git
run: |
sudo apt-get update -q
sudo apt-get install -y git
- name: Run tests
run: |
cd $GITHUB_WORKSPACE
./.github/workflows/scripts/run-tests.sh
27 changes: 0 additions & 27 deletions .travis.yml

This file was deleted.

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
[GlobaLeaks](https://www.globaleaks.org/) is free, open source software enabling anyone to easily set up and maintain a secure whistleblowing platform.

## Continuous integration and testing
| Branch | Status | Quality | Coverage | Documentation
| :---: | :---: | :---: | :---: | :---: |
| [main](https://github.com/globaleaks/GlobaLeaks/tree/main) | [![Build Status](https://travis-ci.com/globaleaks/GlobaLeaks.svg?branch=main)](https://app.travis-ci.com/github/globaleaks/GlobaLeaks) | [![Codacy Badge](https://app.codacy.com/project/badge/Grade/c09f1ec9607f4546924d19798a98dd7d?branch=main)](https://app.codacy.com/gh/globaleaks/GlobaLeaks/dashboard) | [![Codacy Badge](https://app.codacy.com/project/badge/Coverage/c09f1ec9607f4546924d19798a98dd7d?branch=main)](https://app.codacy.com/gh/globaleaks/GlobaLeaks/dashboard) | [![Build Status](https://readthedocs.org/projects/globaleaks/badge/?version=main&style=flat)](https://docs.globaleaks.org/en/main/)
| [devel](https://github.com/globaleaks/GlobaLeaks/tree/devel) | [![Build Status](https://travis-ci.com/globaleaks/GlobaLeaks.svg?branch=devel)](https://app.travis-ci.com/github/globaleaks/GlobaLeaks) | [![Codacy Badge](https://app.codacy.com/project/badge/Grade/c09f1ec9607f4546924d19798a98dd7d?branch=devel)](https://app.codacy.com/gh/globaleaks/GlobaLeaks/dashboard?branch=devel) | [![Codacy Badge](https://app.codacy.com/project/badge/Coverage/c09f1ec9607f4546924d19798a98dd7d?branch=devel)](https://app.codacy.com/gh/globaleaks/GlobaLeaks/dashboard?branch=devel) | [![Build Status](https://readthedocs.org/projects/globaleaks/badge/?version=devel&style=flat)](https://docs.globaleaks.org/en/devel/)
| Branch | Build Status | Test Status | Quality | Coverage | Documentation
| :---: | :---: | :---: | :---: | :---: | :---: |
| [main](https://github.com/globaleaks/GlobaLeaks/tree/main) | [![build workflow](https://github.com/globaleaks/GlobaLeaks/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/globaleaks/GlobaLeaks/actions/workflows/build.yml?query=branch%3Amain) | [![build workflow](https://github.com/globaleaks/GlobaLeaks/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/globaleaks/GlobaLeaks/actions/workflows/test.yml?query=branch%3Amain) | [![Codacy Badge](https://app.codacy.com/project/badge/Grade/c09f1ec9607f4546924d19798a98dd7d?branch=main)](https://app.codacy.com/gh/globaleaks/GlobaLeaks/dashboard) | [![Codacy Badge](https://app.codacy.com/project/badge/Coverage/c09f1ec9607f4546924d19798a98dd7d?branch=main)](https://app.codacy.com/gh/globaleaks/GlobaLeaks/dashboard) | [![Build Status](https://readthedocs.org/projects/globaleaks/badge/?version=main&style=flat)](https://docs.globaleaks.org/en/main/)
| [devel](https://github.com/globaleaks/GlobaLeaks/tree/devel) | [![build workflow](https://github.com/globaleaks/GlobaLeaks/actions/workflows/build.yml/badge.svg?branch=devel)](https://github.com/globaleaks/GlobaLeaks/actions/workflows/build.yml?query=branch%3Adevel) | [![build workflow](https://github.com/globaleaks/GlobaLeaks/actions/workflows/build.yml/badge.svg?branch=devel)](https://github.com/globaleaks/GlobaLeaks/actions/workflows/test.yml?query=branch%3Adevel) | [![Codacy Badge](https://app.codacy.com/project/badge/Grade/c09f1ec9607f4546924d19798a98dd7d?branch=devel)](https://app.codacy.com/gh/globaleaks/GlobaLeaks/dashboard?branch=devel) | [![Codacy Badge](https://app.codacy.com/project/badge/Coverage/c09f1ec9607f4546924d19798a98dd7d?branch=devel)](https://app.codacy.com/gh/globaleaks/GlobaLeaks/dashboard?branch=devel) | [![Build Status](https://readthedocs.org/projects/globaleaks/badge/?version=devel&style=flat)](https://docs.globaleaks.org/en/devel/)

Project best practices and scores:
| Metric | Score
Expand Down
12 changes: 0 additions & 12 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,6 @@ dpkg-reconfigure -f noninteractive tzdata

DO "apt-get -y install gnupg net-tools software-properties-common wget"

function is_tcp_sock_free_check {
! netstat -tlpn 2>/dev/null | grep -F $1 -q
}

# check the required sockets to see if they are already used
for SOCK in "0.0.0.0:80" "0.0.0.0:443" "127.0.0.1:8082" "127.0.0.1:8083"
do
DO "is_tcp_sock_free_check $SOCK"
done

echo " + required TCP sockets open"

# The supported platforms are experimentally more than only Ubuntu as
# publicly communicated to users.
#
Expand Down
99 changes: 0 additions & 99 deletions travis/script.sh

This file was deleted.

0 comments on commit b5241f6

Please sign in to comment.