Skip to content

Commit

Permalink
Refractor v2 (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
nguy8tri authored Sep 21, 2024
1 parent 0a466d3 commit f370c67
Show file tree
Hide file tree
Showing 18 changed files with 3,073 additions and 64 deletions.
98 changes: 85 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,94 @@
name: Build, Test, and Lint
name: Build, Test, Lint, Coverage, and Documentation
on:
push:
branches: [ "master" ]
branches: [ "main" ]
pull_request:
branches: [ "master" ]
branches: ["main"]
types:
- opened
- synchronize
- reopened

jobs:
build-and-test:
build:
runs-on: ubuntu-latest
container: huskysat/found:latest
container: nguy8tri/huskysat:latest

steps:
- uses: actions/checkout@v3
- run: apt -y upgrade
- run: apt install -y cmake
- run: apt install -y wget
- run: apt install -y tar
- run: apt install -y valgrind
- run: pip install cpplint
- uses: actions/checkout@v4

- name: Build all (Twice)
run: (make || make) && make clean
run: (make compile || make compile)

test:
runs-on: ubuntu-latest
container: nguy8tri/huskysat:latest

steps:
- uses: actions/checkout@v4

- name: Test (Twice)
run: (make test || make test)

lint:
runs-on: ubuntu-latest
container: nguy8tri/huskysat:latest
steps:
- uses: actions/checkout@v4

- name: Stylecheck
run: make google_stylecheck

- name: Test Stylecheck
run: make google_stylecheck_test

- name: Line Endings
uses: erclu/check-crlf@v1

coverage:
runs-on: ubuntu-latest
container: nguy8tri/huskysat:latest
steps:
- uses: actions/checkout@v4

- name: Coverage (Twice)
run: (make coverage || make coverage)

- name: Upload Coverage Report
uses: actions/upload-artifact@v4
with:
name: Coverage Report
path: build/documentation/coverage

documentation:
runs-on: ubuntu-latest
container: nguy8tri/huskysat:latest
needs: [build, lint, coverage]
steps:
- uses: actions/checkout@v4

- name: Coverage
run: make coverage

- name: Doxygen
run: make doxygen_generate

- name: Install rsync
run: apt install -y rsync

- name: Set Target Folder in documentation
id: set-folder
run: |
if [ "${{ github.ref_name }}" = "main" ]; then
echo "TARGET_FOLDER=." >> $GITHUB_ENV
else
echo "TARGET_FOLDER=${{ github.ref_name }}" >> $GITHUB_ENV
fi
shell: bash

- name: Upload Pages Artifact
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: documentation
folder: build/documentation/
target-folder: ${{ env.TARGET_FOLDER }}
38 changes: 38 additions & 0 deletions .github/workflows/close-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Cleanup PR

on:
pull_request:
types:
- closed

jobs:
cleanup:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: documentation

- name: Delete coverage/documentation for ${{ github.event.pull_request.number }} from documentation branch
run: |
folder_to_delete="${{ github.event.pull_request.number }}/merge"
echo "Deleting folder: $folder_to_delete from documentation"
rm -rf "$folder_to_delete"
git rm -r "$folder_to_delete" || true
- name: Configure Git for Pushing Deletion change
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Commit Deletion Change
run: |
git add -A
pr="${{ github.event.pull_request.number }}"
git commit -m "Remove folder ${pr}/merge from documentation branch because PR ${pr} is closed"
- name: Pushing Deletion Change
run: |
git push origin documentation
48 changes: 48 additions & 0 deletions .github/workflows/pr-artifacts-link.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Update PR Description with Build Artifacts

on:
pull_request:
branches: [ "main" ]
types: [opened, edited, synchronize]

jobs:
update-description:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Get PR number
id: get-pr-number
run: echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV

- name: Update PR description
uses: actions/github-script@v7
with:
script: |
const prNumber = process.env.PR_NUMBER;
const prFooter = `# Artifacts for PR #${prNumber} (DO NOT CHANGE)`;
const artifactLinks = `- [Coverage Artifact](https://uwcubesat.github.io/found/${prNumber}/merge/coverage)\n`
+ `- [Doxygen Artifact](https://uwcubesat.github.io/found/${prNumber}/merge/doxygen)\n`;
const { data: pr } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber,
});
// Check if both artifact links are already present in the PR body
if (pr.body.includes("Artifacts for PR")) {
console.log('PR description already has documentation artifacts');
} else {
const newPrBody = `# Description\n${pr.body}\n\n${prFooter}\n${artifactLinks.trim()}`;
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber,
body: newPrBody,
});
console.log('PR description updated with documentation artifacts');
}
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM ubuntu:latest
RUN apt update
RUN apt -y upgrade
RUN apt install -y git
RUN apt install -y g++
RUN apt install -y cmake
RUN apt install -y wget
RUN apt install -y tar
RUN apt install -y valgrind
RUN apt install -y python3
RUN apt install -y cpplint
RUN apt install -y gcovr
RUN apt install -y doxygen
RUN apt install -y graphviz
Loading

0 comments on commit f370c67

Please sign in to comment.