Skip to content

Commit

Permalink
merged refactoring changes from main
Browse files Browse the repository at this point in the history
  • Loading branch information
tan7271 committed Sep 26, 2024
2 parents 8c1e92f + f370c67 commit 28dcf6b
Show file tree
Hide file tree
Showing 35 changed files with 3,610 additions and 18,435 deletions.
94 changes: 94 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Build, Test, Lint, Coverage, and Documentation
on:
push:
branches: [ "main" ]
pull_request:
branches: ["main"]
types:
- opened
- synchronize
- reopened

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

steps:
- uses: actions/checkout@v4

- name: Build all (Twice)
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');
}
10 changes: 7 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
*.o
# Don't include the build folder
build

found
found-test
# Don't include personal .vscode settings
.vscode

# Don't include google test stuff
googletest*
18 changes: 0 additions & 18 deletions .vscode/c_cpp_properties.json

This file was deleted.

63 changes: 0 additions & 63 deletions .vscode/settings.json

This file was deleted.

6 changes: 6 additions & 0 deletions CPPLINT.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
filter= -legal/copyright
filter= -readability/todo
filter= -whitespace/comma
filter= -runtime/references
filter= -build/header_guard
linelength=120
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 28dcf6b

Please sign in to comment.