Skip to content

Commit

Permalink
ci update for valgrind
Browse files Browse the repository at this point in the history
  • Loading branch information
Ximaz committed Apr 28, 2024
1 parent 0c78b19 commit b9d41d4
Showing 1 changed file with 64 additions and 109 deletions.
173 changes: 64 additions & 109 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,15 @@
# Specifications for this workflow
#
# The jobs will be trigger on any push/pull_request as long as the main branch
# is not the source of those events.
#
# -----------------------------------------------------------------------------
# | SECRETS |
# -----------------------------------------------------------------------------
# | -> Repository Secrets (not the Environment Secrets) |
# -----------------------------------------------------------------------------
#
# PERSONNAL_ACCESS_TOKEN: should be a fine-grained token. Permissions are :
# - Contents: "Read and Write"
# - Metadata (mandatory): "Read Only"
# - Pull Requests: "Read Only"
#
# SSH_PRIVATE_KEY: an SSH private key able to push commits to the ${MIRROR_URL}
# repository (see below). This private key MUST NOT be protected by a
# passphrase as for now, the pixta-dev/repository-mirroring-action action
# doesn't support it
#
# SSH_PRIVATE_KEY_PASSPHRASE: the passphrase used to craft the SSH_PRIVATE_KEY.
#
# -----------------------------------------------------------------------------
# | VARIABLES |
# -----------------------------------------------------------------------------
# | -> Repository Variables (not the Environment Variables) |
# -----------------------------------------------------------------------------
#
# ARTIFACTSS: space-separated artifactss generated by the `make` command.
#
# MIRROR_URL: the mirror repository URL in an SSH format :
# git@<host>:<username>/<repository>
#
# -----------------------------------------------------------------------------
# | WORKFLOW |
# -----------------------------------------------------------------------------
#
# The `Workflow Permission` must be set to "Read and Write".
#

name: "ci"

on:
- push
- pull_request

env:
UNIT_TESTS: "./unit_tests"
VALGRIND_REPORTS: "./valgrind-reports.log"
ARTIFACTS: "${{ vars.ARTIFACTS }}"
MIRROR_URL: "${{ vars.MIRROR_URL }}"
SSH_PRIVATE_KEY: "${{ secrets.SSH_PRIVATE_KEY }}"
SSH_PRIVATE_KEY_PASSPHRASE: "${{ secrets.SSH_PRIVATE_KEY_PASSPHRASE }}"

jobs:
check-basics:
Expand All @@ -53,16 +19,14 @@ jobs:
steps:
- id: "basic-check"
continue-on-error: true
env:
ARTIFACTS: "${{ vars.ARTIFACTS }}"
if: "${{ env.ARTIFACTS }}"
run: "echo \"continue=1\" >> $GITHUB_OUTPUT"

basics:
needs:
- "check-basics"
runs-on: "ubuntu-latest"
if: "${{ needs.check-basics.outputs.continue == '1' && format('refs/heads/{0}', github.event.repository.default_branch) != github.ref }}"
if: "${{ needs.check-basics.outputs.continue == '1' }}"
container:
image: "ghcr.io/epitech/coding-style-checker:latest"
steps:
Expand All @@ -75,38 +39,19 @@ jobs:
run: "[[ $(find . -type f \\( -name '*.o' -o -name '*.log' -o -name '.env' -o -name '*.so' -o -name '*.a' -o -name '*.gcno' -o -name '*.gcda' \\)) == \"\" ]] && exit 0 || exit 1"

- name: "Checking for the artifacts before compilation"
run: "for a in ${{ vars.ARTIFACTS }} ; do [ ! -f \"${a}\" ]; done"

- name: "Check coding style"
run: "/usr/local/bin/check.sh $(pwd) $(pwd)"

- name: "Annotate coding-style errors"
run: |
status=0
while IFS= read -r line; do
file=$(echo "${line}" | cut -d ':' -f1)
pos=$(echo "${line}" | cut -d ':' -f2)
type=$(echo "${line}" | cut -d ':' -f3)
csid=$(echo "${line}" | cut -d ':' -f4)
[[ "${type:1}" == "illegal"* ]] && continue
echo "::error file=${file},line=${pos},title=${type:1} ${csid}::${type:1}: ${csid} at ${file}:${pos}"
status=1
done < coding-style-reports.log
rm -f coding-style-reports.log
exit "${status}"
run: "for a in ${{ env.ARTIFACTS }} ; do [ ! -f \"${a}\" ]; done"

- name: "Checking make on it's own"
timeout-minutes: 1
run: "make && for a in ${{ vars.ARTIFACTS }}; do [ -f \"${a}\" ]; done"
run: "make && for a in ${{ env.ARTIFACTS }}; do [ -f \"${a}\" ]; done"

- name: "Checking for make relink on it's own"
timeout-minutes: 1
run: "[[ $(make) == \"\" ]] && exit 1 || echo 0"

- name: "Checking 'all' rule"
timeout-minutes: 1
run: "make all && for a in ${{ vars.ARTIFACTS }}; do [ -f \"${a}\" ]; done"
run: "make all && for a in ${{ env.ARTIFACTS }}; do [ -f \"${a}\" ]; done"

- name: "Checking for 'all' make relink"
timeout-minutes: 1
Expand All @@ -121,7 +66,7 @@ jobs:
run: |
make
make fclean
for a in ${{ vars.ARTIFACTS }}; do [ ! -f "${a}" ]; done
for a in ${{ env.ARTIFACTS }}; do [ ! -f "${a}" ]; done
if [[ $(find . -type d -name '.git' -prune -o \( -type f \( -name '*.o' -o -name '*.log' -o -name '.env' -o -name '*.so' -o -name '*.a' -o -name '*.gcno' -o -name '*.gcda' \) \) -print) == "" ]]; then
exit 0
else
Expand All @@ -132,25 +77,45 @@ jobs:
timeout-minutes: 1
run: |
make re
for a in ${{ vars.ARTIFACTS }} ; do [ -f "${a}" ]; done
for a in ${{ env.ARTIFACTS }} ; do [ -f "${a}" ]; done
- name: "Checking the artifacts rule"
timeout-minutes: 1
run: |
for a in ${{ vars.ARTIFACTS }}; do make "${a}" && [ -f "${a}" ]; done
for a in ${{ env.ARTIFACTS }}; do make "${a}" && [ -f "${a}" ]; done
- name: "Checking for the artifacts make relink"
timeout-minutes: 1
run: |
for a in ${{ vars.ARTIFACTS }}; do
for a in ${{ env.ARTIFACTS }}; do
if [[ $(make "${a}") == "" ]]; then exit 1; fi;
done
- name: "Clean up"
run: "make fclean"

- name: "Check coding style"
run: "/usr/local/bin/check.sh $(pwd) $(pwd)"

- name: "Annotate coding-style errors"
run: |
status=0
while IFS= read -r line; do
file=$(echo "${line}" | cut -d ':' -f1)
pos=$(echo "${line}" | cut -d ':' -f2)
type=$(echo "${line}" | cut -d ':' -f3)
csid=$(echo "${line}" | cut -d ':' -f4)
[[ "${type:1}" == "illegal"* ]] && continue
echo "::error file=${file},line=${pos},title=${type:1} ${csid}::${type:1}: ${csid} at ${file}:${pos}"
status=1
done < coding-style-reports.log
exit "${status}"
run-tests:
needs:
- "basics"
runs-on: "ubuntu-latest"
if: "${{ format('refs/head/{0}', github.event.repository.default_branch) != github.ref }}"
container:
image: "epitechcontent/epitest-docker:latest"
steps:
Expand All @@ -163,56 +128,46 @@ jobs:
timeout-minutes: 1
run: "[[ $(grep -E \"^tests_run:\" Makefile) == \"\" ]] && exit 0 || make tests_run"

check-push-commits:
runs-on: "ubuntu-latest"
needs:
- "basics"
- "run-tests"
outputs:
continue: "${{ steps.publishing-check.outputs.continue }}"
steps:
- id: "publishing-check"
continue-on-error: true
env:
PERSONNAL_ACCESS_TOKEN: "${{ secrets.PERSONNAL_ACCESS_TOKEN }}"
if: "${{ env.PERSONNAL_ACCESS_TOKEN }}"
run: "echo \"continue=1\" >> $GITHUB_OUTPUT"

push-commits:
needs:
- "check-push-commits"
runs-on: "ubuntu-latest"
if: "${{ needs.check-push-commits.outputs.continue == '1' && format('refs/heads/{0}', github.event.repository.default_branch) != github.ref }}"
steps:
- name: "Checkout"
uses: "actions/checkout@v4.1.1"
with:
fetch-depth: 0
- name: "Run valgrind"
run: "[ -f \"${{ env.UNIT_TESTS }}\" ] && valgrind -s --leak-check=full --track-origins=yes --read-var-info=yes --trace-children=yes --show-leak-kinds=all --read-inline-info=yes --errors-for-leak-kinds=all ${{ env.UNIT_TESTS }} 2>${{ env.VALGRIND_REPORTS }}"

- name: "Push all commits"
env:
GITHUB_TOKEN: "${{ secrets.PERSONNAL_ACCESS_TOKEN }}"
run: "git push origin ${{ github.ref_name }}:${{ github.event.repository.default_branch }}"
- name: "Analyze valgrind report"
run: |
[ ! -f "${{ env.VALGRIND_REPORTS }}" ] && exit 0
status=0
block=""
while IFS= read -r line; do
if [[ "${block}" != "" ]]; then
if [[ $(echo "${line}" | grep '^==.*== $') ]]; then
echo "::error title=Valgrind Error::${block}"
block=""
status=1
else
block="${block}%0A${line}"
fi
fi
if [[ $(echo "${line}" | grep '^==.*== .* bytes in .* blocks are definitely lost in loss record .* of .*$') ]]; then
block="${line}"
fi
done < ${{ env.VALGRIND_REPORTS }}
exit "${status}"
check-mirror-commits:
runs-on: "ubuntu-latest"
needs:
- "push-commits"
- "run-tests"
outputs:
continue: "${{ steps.mirroring-check.outputs.continue }}"
steps:
- id: "mirroring-check"
continue-on-error: true
env:
MIRROR_URL: "${{ vars.MIRROR_URL }}"
SSH_PRIVATE_KEY: "${{ secrets.SSH_PRIVATE_KEY }}"
if: "${{ env.MIRROR_URL && env.SSH_PRIVATE_KEY }}"
run: "echo \"continue=1\" >> $GITHUB_OUTPUT"

mirror-commits:
needs:
- "check-mirror-commits"
if: "${{ needs.check-mirror-commits.outputs.continue == '1' && github.event_name == 'push' && format('refs/heads/{0}', github.event.repository.default_branch) != github.ref }}"
if: "${{ needs.check-mirror-commits.outputs.continue == '1' }}"
runs-on: "ubuntu-latest"
steps:
- name: "Checkout"
Expand All @@ -223,6 +178,6 @@ jobs:
- name: "Mirror commits"
uses: "./.github/workflows/repository-mirroring-action"
with:
target_repo_url: "${{ vars.MIRROR_URL }}"
ssh_private_key: "${{ secrets.SSH_PRIVATE_KEY }}"
ssh_private_key_passphrase: "${{ secrets.SSH_PRIVATE_KEY_PASSPHRASE }}"
target_repo_url: "${{ env.MIRROR_URL }}"
ssh_private_key: "${{ env.SSH_PRIVATE_KEY }}"
ssh_private_key_passphrase: "${{ env.SSH_PRIVATE_KEY_PASSPHRASE }}"

0 comments on commit b9d41d4

Please sign in to comment.