Skip to content

Commit

Permalink
Fix #71, Reuse CodeQL, Static Analysis, and Format Check
Browse files Browse the repository at this point in the history
  • Loading branch information
arielswalker committed Oct 28, 2021
1 parent 5acb286 commit 0db812d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 185 deletions.
115 changes: 6 additions & 109 deletions .github/workflows/codeql-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,114 +3,11 @@ name: "CodeQL Analysis"
on:
push:
pull_request:
branches:
- main

env:
SIMULATION: native
ENABLE_UNIT_TESTS: true
OMIT_DEPRECATED: true
BUILDTYPE: release

jobs:
#Checks for duplicate actions. Skips push actions if there is a matching or duplicate pull-request action.
check-for-duplicates:
runs-on: ubuntu-latest
# Map a step output to a job output
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@master
with:
concurrent_skipping: 'same_content'
skip_after_successful_duplicate: 'true'
do_not_skip: '["pull_request", "workflow_dispatch", "schedule"]'

CodeQL-Security-Build:
needs: check-for-duplicates
if: ${{ needs.check-for-duplicates.outputs.should_skip != 'true' }}
runs-on: ubuntu-18.04
timeout-minutes: 15

steps:
# Checks out a copy of your repository on the ubuntu-latest machine
- name: Checkout bundle
uses: actions/checkout@v2
with:
repository: nasa/cFS
submodules: true

- name: Checkout submodule
uses: actions/checkout@v2
with:
path: apps/sample_lib

- name: Check versions
run: git submodule

- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: c
config-file: nasa/cFS/.github/codeql/codeql-security.yml@main

# Setup the build system
- name: Set up for build
run: |
cp ./cfe/cmake/Makefile.sample Makefile
cp -r ./cfe/cmake/sample_defs sample_defs
make prep
# Build the code
- name: Build
run: |
make sample_lib
make native/default_cpu1/apps/sample_lib/unit-test/
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1

CodeQL-Coding-Standard-Build:
needs: check-for-duplicates
if: ${{ needs.check-for-duplicates.outputs.should_skip != 'true' }}
runs-on: ubuntu-18.04
timeout-minutes: 15

steps:
# Checks out a copy of your repository on the ubuntu-latest machine
- name: Checkout bundle
uses: actions/checkout@v2
with:
repository: nasa/cFS
submodules: true

- name: Checkout submodule
uses: actions/checkout@v2
with:
path: apps/sample_lib

- name: Check versions
run: git submodule

- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: c
config-file: nasa/cFS/.github/codeql/codeql-coding-standard.yml@main

# Setup the build system
- name: Set up for build
run: |
cp ./cfe/cmake/Makefile.sample Makefile
cp -r ./cfe/cmake/sample_defs sample_defs
make prep
# Build the code
- name: Build
run: |
make sample_lib
make native/default_cpu1/apps/sample_lib/unit-test/
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
codeql:
name: Codeql
uses: nasa/cFS/.github/workflows/codeql-build.yml@main
with:
make-prep: 'make prep'
make: 'make sample_lib && make native/default_cpu1/apps/sample_lib/unit-test/'
48 changes: 3 additions & 45 deletions .github/workflows/format-check.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,11 @@
name: Format Check

# Run on main push and pull requests
# Run on all push and pull requests
on:
push:
branches:
- main
pull_request:

jobs:

static-analysis:
format-check:
name: Run format check
runs-on: ubuntu-18.04
timeout-minutes: 15

steps:

- name: Install format checker
run: |
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo add-apt-repository 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main'
sudo apt-get update && sudo apt-get install clang-format-10
- name: Checkout bundle
uses: actions/checkout@v2
with:
repository: nasa/cFS

- name: Checkout
uses: actions/checkout@v2
with:
path: repo

- name: Generate format differences
run: |
cd repo
find . -name "*.[ch]" -exec clang-format-10 -i -style=file {} +
git diff > $GITHUB_WORKSPACE/style_differences.txt
- name: Archive Static Analysis Artifacts
uses: actions/upload-artifact@v2
with:
name: style_differences
path: style_differences.txt

- name: Error on differences
run: |
if [[ -s style_differences.txt ]];
then
cat style_differences.txt
exit -1
fi
uses: nasa/cFS/.github/workflows/format-check.yml@main
33 changes: 2 additions & 31 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,11 @@
name: Static Analysis

# Run on main push and pull requests
# Run on all push and pull requests
on:
push:
branches:
- main
pull_request:

jobs:

static-analysis:
name: Run cppcheck
runs-on: ubuntu-18.04
timeout-minutes: 15

steps:

- name: Install cppcheck
run: sudo apt-get install cppcheck -y

- name: Checkout code
uses: actions/checkout@v2

- name: Run general cppcheck
run: cppcheck --force --inline-suppr --quiet . 2> cppcheck_err.txt

- name: Archive Static Analysis Artifacts
uses: actions/upload-artifact@v2
with:
name: cppcheck-err
path: ./cppcheck_err.txt

- name: Check for errors
run: |
if [[ -s cppcheck_err.txt ]];
then
cat cppcheck_err.txt
exit -1
fi
uses: nasa/cFS/.github/workflows/static-analysis.yml@main
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Changelog

## [v1.2.0-rc1](https://github.com/ArielSAdamsNASA/sample_lib/tree/v1.2.0-rc1) (2020-08-05)

[Full Changelog](https://github.com/ArielSAdamsNASA/sample_lib/compare/v1.1.0...v1.2.0-rc1)

## [v1.1.0](https://github.com/ArielSAdamsNASA/sample_lib/tree/v1.1.0) (2019-12-19)

[Full Changelog](https://github.com/ArielSAdamsNASA/sample_lib/compare/v1.0.0a...v1.1.0)

## [v1.0.0a](https://github.com/ArielSAdamsNASA/sample_lib/tree/v1.0.0a) (2019-06-24)

[Full Changelog](https://github.com/ArielSAdamsNASA/sample_lib/compare/813b4c2c1aabbf3ddd87487386540f2829e015d5...v1.0.0a)



\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*

0 comments on commit 0db812d

Please sign in to comment.