Skip to content

Commit

Permalink
Refactor README.md badges in order to host more metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
evilaliv3 committed Nov 18, 2024
1 parent b8dfa57 commit 5e89280
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 87 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ jobs:
- name: Run tests
run: |
cd $GITHUB_WORKSPACE
./.github/workflows/scripts/run-build.sh
./.github/workflows/scripts/run_build.sh
73 changes: 0 additions & 73 deletions .github/workflows/scripts/run-tests.sh

This file was deleted.

File renamed without changes.
32 changes: 32 additions & 0 deletions .github/workflows/scripts/run_tests_backend.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

backend_test_failed=0

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

echo "Running setup"
sudo apt-get update
sudo apt-get install -y tor
pip install coverage
setupBackend

# Running backend tests
echo "Running backend tests"
cd $GITHUB_WORKSPACE/backend && coverage run setup.py test
if [ $? -ne 0 ]; then
backend_test_failed=1
fi

cd $GITHUB_WORKSPACE/backend && coverage xml
bash <(curl -Ls https://coverage.codacy.com/get.sh) report -l Python -r $GITHUB_WORKSPACE/backend/coverage.xml

if [ $backend_test_failed -eq 1 ]; then
echo "Backend unit tests: FAILED"
exit 1
else
echo "Backend unit tests: PASSED"
exit 0
fi
41 changes: 41 additions & 0 deletions .github/workflows/scripts/run_tests_client.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

client_test_failed=0

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

setupClient() {
cd $GITHUB_WORKSPACE/client # to install frontend dependencies
npm install -d
./node_modules/grunt/bin/grunt build_and_instrument
}

echo "Running setup"
sudo apt-get update
sudo apt-get install -y tor
npm install -g grunt grunt-cli
setupBackend
setupClient

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

# Running client tests locally
echo "Running client tests locally collecting code coverage"
cd $GITHUB_WORKSPACE/client && npm test
if [ $? -ne 0 ]; then
client_test_failed=1
fi

bash <(curl -Ls https://coverage.codacy.com/get.sh) report -l TypeScript -r $GITHUB_WORKSPACE/client/cypress/coverage/lcov.info

if [ $client_test_failed -eq 1 ]; then
echo "Client tests: FAILED"
exit 1
else
echo "Client tests: PASSED"
exit 0
fi
28 changes: 28 additions & 0 deletions .github/workflows/test-backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Tests (B)

on: [ push, pull_request ]

# Declare default permissions as read only.
permissions: read-all

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

jobs:
run_tests:
runs-on: "ubuntu-latest"
steps:
- name: Check out repository code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 1

- 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_backend.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test
name: Tests (C)

on: [ push, pull_request ]

Expand All @@ -25,4 +25,4 @@ jobs:
- name: Run tests
run: |
cd $GITHUB_WORKSPACE
./.github/workflows/scripts/run-tests.sh
./.github/workflows/scripts/run_tests_client.sh
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@
The software is recognized by the [Digital Public Good Alliance](https://digitalpublicgoods.net) as a [Digital Public Good](https://app.digitalpublicgoods.net/a/11113).

## Continuous integration and testing
| Branch | Build Status | Test Status | Quality | Coverage | Documentation
| :---: | :---: | :---: | :---: | :---: | :---: |
| [stable](https://github.com/globaleaks/globaleaks-whistleblowing-software/tree/stable) | [![build workflow](https://github.com/globaleaks/globaleaks-whistleblowing-software/actions/workflows/build.yml/badge.svg?branch=stable)](https://github.com/globaleaks/globaleaks-whistleblowing-software/actions/workflows/build.yml?query=branch%3Astable) | [![build workflow](https://github.com/globaleaks/globaleaks-whistleblowing-software/actions/workflows/test.yml/badge.svg?branch=stable)](https://github.com/globaleaks/globaleaks-whistleblowing-software/actions/workflows/test.yml?query=branch%3Astable) | [![Codacy Badge](https://app.codacy.com/project/badge/Grade/c09f1ec9607f4546924d19798a98dd7d?branch=stable)](https://app.codacy.com/gh/globaleaks/globaleaks-whistleblowing-software/dashboard) | [![Codacy Badge](https://app.codacy.com/project/badge/Coverage/c09f1ec9607f4546924d19798a98dd7d?branch=stable)](https://app.codacy.com/gh/globaleaks/globaleaks-whistleblowing-software/dashboard) | [![Build Status](https://readthedocs.org/projects/globaleaks/badge/?version=stable&style=flat)](https://docs.globaleaks.org/en/stable/)
| [devel](https://github.com/globaleaks/globaleaks-whistleblowing-software/tree/devel) | [![build workflow](https://github.com/globaleaks/globaleaks-whistleblowing-software/actions/workflows/build.yml/badge.svg?branch=devel)](https://github.com/globaleaks/globaleaks-whistleblowing-software/actions/workflows/build.yml?query=branch%3Adevel) | [![test workflow](https://github.com/globaleaks/globaleaks-whistleblowing-software/actions/workflows/test.yml/badge.svg?branch=devel)](https://github.com/globaleaks/globaleaks-whistleblowing-software/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-whistleblowing-software/dashboard?branch=devel) | [![Codacy Badge](https://app.codacy.com/project/badge/Coverage/c09f1ec9607f4546924d19798a98dd7d?branch=devel)](https://app.codacy.com/gh/globaleaks/globaleaks-whistleblowing-software/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 | [Stable branch](https://github.com/globaleaks/globaleaks-whistleblowing-software/tree/stable) | [Devel branch](https://github.com/globaleaks/globaleaks-whistleblowing-software/tree/devel) |
| :---- | :---- | :---- |
| Build Status | [![build workflow](https://github.com/globaleaks/globaleaks-whistleblowing-software/actions/workflows/build.yml/badge.svg?branch=stable)](https://github.com/globaleaks/globaleaks-whistleblowing-software/actions/workflows/build.yml?query=branch%3Astable) | [![build workflow](https://github.com/globaleaks/globaleaks-whistleblowing-software/actions/workflows/build.yml/badge.svg?branch=devel)](https://github.com/globaleaks/globaleaks-whistleblowing-software/actions/workflows/build.yml?query=branch%3Adevel) |
| Tests (Backend): | [![build workflow](https://github.com/globaleaks/globaleaks-whistleblowing-software/actions/workflows/test-backend.yml/badge.svg?branch=stable)](https://github.com/globaleaks/globaleaks-whistleblowing-software/actions/workflows/test-backend.yml?query=branch%3Astable) | [![build workflow](https://github.com/globaleaks/globaleaks-whistleblowing-software/actions/workflows/test-backend.yml/badge.svg?branch=devel)](https://github.com/globaleaks/globaleaks-whistleblowing-software/actions/workflows/test-backend.yml?query=branch%3Adevel) |
| Tests (Client): | [![build workflow](https://github.com/globaleaks/globaleaks-whistleblowing-software/actions/workflows/test-client.yml/badge.svg?branch=stable)](https://github.com/globaleaks/globaleaks-whistleblowing-software/actions/workflows/test-client.yml?query=branch%3Astable) | [![build workflow](https://github.com/globaleaks/globaleaks-whistleblowing-software/actions/workflows/test-client.yml/badge.svg?branch=devel)](https://github.com/globaleaks/globaleaks-whistleblowing-software/actions/workflows/test-client.yml?query=branch%3Adevel) |
| Tests Coverage: | [![Codacy Badge](https://app.codacy.com/project/badge/Coverage/c09f1ec9607f4546924d19798a98dd7d?branch=stable)](https://app.codacy.com/gh/globaleaks/globaleaks-whistleblowing-software/dashboard) | [![Codacy Badge](https://app.codacy.com/project/badge/Coverage/c09f1ec9607f4546924d19798a98dd7d?branch=devel)](https://app.codacy.com/gh/globaleaks/globaleaks-whistleblowing-software/dashboard) |
| Code Quality: | [![Codacy Badge](https://app.codacy.com/project/badge/Grade/c09f1ec9607f4546924d19798a98dd7d?branch=stable)](https://app.codacy.com/gh/globaleaks/globaleaks-whistleblowing-software/dashboard) | [![Codacy Badge](https://app.codacy.com/project/badge/Grade/c09f1ec9607f4546924d19798a98dd7d?branch=devel)](https://app.codacy.com/gh/globaleaks/globaleaks-whistleblowing-software/dashboard) |
| Documentation | [![Build Status](https://readthedocs.org/projects/globaleaks/badge/?version=stable&style=flat)](https://docs.globaleaks.org/en/stable/) | [![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
| :---: | :---: |
| :---- | :---- |
| [OpenSSF Scorecard](https://scorecard.dev/) | [![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/globaleaks/globaleaks-whistleblowing-software/badge)](https://scorecard.dev/viewer/?uri=github.com/globaleaks/globaleaks-whistleblowing-software)
| [OpenSSF Best Practices](https://bestpractices.coreinfrastructure.org/) | [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/3816/badge)](https://bestpractices.coreinfrastructure.org/projects/3816)
| [MDN HTTP Observatory](https://developer.mozilla.org/en-US/observatory/analyze?host=try.globaleaks.org) | ![Status](https://img.shields.io/badge/observatory-A%2B-brightgreen)
Expand Down
10 changes: 6 additions & 4 deletions backend/globaleaks/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
this_directory = os.path.dirname(__file__)

possible_client_paths = [
os.path.abspath(os.path.join(this_directory, '../../client/build/')),
'/usr/share/globaleaks/client'
'/usr/share/globaleaks/client',
os.path.abspath(os.path.join(this_directory, '../../client/build/'))
]


Expand Down Expand Up @@ -98,14 +98,16 @@ def eval_paths(self):
self.accesslogfile = os.path.abspath(os.path.join(self.log_path, "access.log"))

# Client path detection
client_found=False
self.client_path = possible_client_paths[0]
for path in possible_client_paths:
if os.path.isfile(os.path.join(path, 'index.html')):
self.client_path = path
client_found=True
break

if self.client_path is None:
if not client_found:
print("Unable to find a directory to load the client from")
sys.exit(1)

self.appdata_file = os.path.join(self.client_path, 'data/appdata.json')
self.questionnaires_path = os.path.join(self.client_path, 'data/questionnaires')
Expand Down

0 comments on commit 5e89280

Please sign in to comment.