fixing coding style #49
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) | | |
# ----------------------------------------------------------------------------- | |
# | |
# ARTIFACT: the artifact that should be 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 | |
jobs: | |
check-basics: | |
runs-on: "ubuntu-latest" | |
outputs: | |
continue: "${{ steps.basic-check.outputs.continue }}" | |
steps: | |
- id: "basic-check" | |
continue-on-error: true | |
env: | |
ARTIFACT: "${{ vars.ARTIFACT }}" | |
if: "${{ env.ARTIFACT }}" | |
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 }}" | |
container: | |
image: "ghcr.io/epitech/coding-style-checker:latest" | |
steps: | |
- name: "Checkout" | |
uses: "actions/checkout@v4.1.1" | |
with: | |
fetch-depth: 0 | |
- name: "Temporary files" | |
run: "[[ $(find . -type f \\( -name '${{ vars.ARTIFACT }}' -o -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: "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}" | |
- name: "Checking make on it's own" | |
timeout-minutes: 1 | |
run: "make && [[ -f \"${{ vars.ARTIFACT }}\" ]] && exit 0 || exit 1" | |
- 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 && [[ -f \"${{ vars.ARTIFACT }}\" ]] && exit 0 || exit 1" | |
- name: "Checking for 'all' make relink" | |
timeout-minutes: 1 | |
run: "[[ $(make all) == \"\" ]] && exit 1 || echo 0" | |
- name: "Checking 'clean' rule" | |
timeout-minutes: 1 | |
run: "make clean && echo $(find . -type d -name '.git' -prune -o \\( -type f \\( -name '*.o' -o -name '.env' -o -name '*.log' -o -name '*.gcno' -o -name '*.gcda' \\) \\) -print) && echo $(find . -type d -name '.git' -prune -o \\( -type f -name '${{ vars.ARTIFACT }}' \\) -print) && [[ $(find . -type d -name '.git' -prune -o \\( -type f \\( -name '*.o' -o -name '.env' -o -name '*.log' -o -name '*.gcno' -o -name '*.gcda' \\) \\) -print) == \"\" ]] && [[ $(find . -type d -name '.git' -prune -o \\( -type f -name '${{ vars.ARTIFACT }}' \\) -print) != \"\" ]] && exit 0 || exit 1" | |
- name: "Checking 'fclean' rule" | |
timeout-minutes: 1 | |
run: "make && make fclean && [[ $(find . -type d -name '.git' -prune -o \\( -type f \\( -name '${{ vars.ARTIFACT }}' -o -name '*.o' -o -name '*.log' -o -name '.env' -o -name '*.so' -o -name '*.a' -o -name '*.gcno' -o -name '*.gcda' \\) \\) -print) == \"\" ]] && exit 0 || exit 1" | |
- name: "Checking 're' rule" | |
timeout-minutes: 1 | |
run: "make re && [[ -f \"${{ vars.ARTIFACT }}\" ]] && exit 0 || exit 1" | |
- name: "Checking the artifact rule" | |
timeout-minutes: 1 | |
run: "make ${{ vars.ARTIFACT }} && [[ -f \"${{ vars.ARTIFACT }}\" ]] && exit 0 || exit 1" | |
- name: "Checking for the artifact make relink" | |
timeout-minutes: 1 | |
run: "[[ $(make ${{ vars.ARTIFACT }}) == \"\" ]] && exit 1 || echo 0" | |
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: | |
- name: "Checkout" | |
uses: "actions/checkout@v4.1.1" | |
with: | |
fetch-depth: 0 | |
- name: "Run tests" | |
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: "Push all commits" | |
env: | |
GITHUB_TOKEN: "${{ secrets.PERSONNAL_ACCESS_TOKEN }}" | |
run: "git push origin ${{ github.ref_name }}:${{ github.event.repository.default_branch }}" | |
check-mirror-commits: | |
runs-on: "ubuntu-latest" | |
needs: | |
- "push-commits" | |
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 }}" | |
runs-on: "ubuntu-latest" | |
steps: | |
- name: "Checkout" | |
uses: "actions/checkout@v4.1.1" | |
with: | |
fetch-depth: 0 | |
- 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 }}" |