diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..6867e71 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file + +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..58de1ec --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,53 @@ +name: Build + +on: + push: + paths: + - 'src/**' + - 'include/**' + - 'Makefile' + - '*.mk' + - '.github/workflows/build.yml' + +jobs: + + build: + name: Build library + + runs-on: ubuntu-latest + env: + CC: gcc + XCHANGE: ../xchange + REDISX: ../redisx + steps: + - name: Check out smax-clib + uses: actions/checkout@v4 + with: + path: smax-clib + + - name: Check out xchange dependency + uses: actions/checkout@v4 + with: + repository: Smithsonian/xchange + path: xchange + + - name: Check out RedisX dependency + uses: actions/checkout@v4 + with: + repository: Smithsonian/redisx + path: redisx + + - name: Build static library + run: make -C smax-clib static + + - name: Build xchange dependency + run: make -C xchange shared + + - name: Build xchange dependency + run: make -C redisx shared + + - name: Build shared library + run: make -C smax-clib shared + + + diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 0000000..ec99360 --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,43 @@ +name: Static Analysis + +on: + push: + paths: + - 'src/**' + - 'include/**' + - 'Makefile' + - '*.mk' + - '.github/workflows/check.yml' + +jobs: + + cppcheck: + name: Check source code + + runs-on: ubuntu-latest + env: + CC: gcc + XCHANGE: xchange + REDISX: redisx + steps: + + - name: Check out smax-clib + uses: actions/checkout@v4 + + - name: Check out xchange dependency + uses: actions/checkout@v4 + with: + repository: Smithsonian/xchange + path: xchange + + - name: Check out RedisX dependency + uses: actions/checkout@v4 + with: + repository: Smithsonian/redisx + path: redisx + + - name: install package dependencies + run: sudo apt-get install -y cppcheck + + - name: Run cppcheck + run: make check diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..04e84e8 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,95 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL Advanced" + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + schedule: + - cron: '35 18 * * 5' + +jobs: + analyze: + name: Analyze (${{ matrix.language }}) + # Runner size impacts CodeQL analysis time. To learn more, please see: + # - https://gh.io/recommended-hardware-resources-for-running-codeql + # - https://gh.io/supported-runners-and-hardware-resources + # - https://gh.io/using-larger-runners (GitHub.com only) + # Consider using larger runners or machines with greater resources for possible analysis time improvements. + runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} + permissions: + # required for all workflows + security-events: write + + # required to fetch internal or private CodeQL packs + packages: read + + # only required for workflows in private repositories + actions: read + contents: read + + strategy: + fail-fast: false + matrix: + include: + - language: c-cpp + build-mode: autobuild + # CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' + # Use `c-cpp` to analyze code written in C, C++ or both + # Use 'java-kotlin' to analyze code written in Java, Kotlin or both + # Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both + # To learn more about changing the languages that are analyzed or customizing the build mode for your analysis, + # see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning. + # If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how + # your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + path: smax-clib + + - name: Checkout xchange dependency + uses: actions/checkout@v4 + with: + repository: Smithsonian/xchange + path: xchange + + - name: Checkout RedisX dependency + uses: actions/checkout@v4 + with: + repository: Smithsonian/redisx + path: redisx + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + build-mode: manual + + - name: Manual build + shell: bash + env: + XCHANGE: ../xchange + REDISX: ../redisx + run: | + make -C xchange shared + make -C redisx shared + make -C smax-clib shared + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 + with: + working-directory: smax-clib + category: "/language:${{matrix.language}}" diff --git a/.github/workflows/dox.yml b/.github/workflows/dox.yml new file mode 100644 index 0000000..f282372 --- /dev/null +++ b/.github/workflows/dox.yml @@ -0,0 +1,150 @@ +name: API documentation + +on: + release: + types: [published] + + push: + paths: + - 'src/**' + - 'include/**' + - 'css/**' + - 'resources/**' + - 'Doxyfile' + - '*.md' + - '.github/workflows/dox.yml' + +jobs: + + apidocs: + name: Generate API documentation + + runs-on: ubuntu-latest + env: + CC: gcc + XCHANGE: xchange + REDISX: redisx + steps: + + - name: install doxygen + run: sudo apt-get install doxygen + + - name: Check out smax-clib + uses: actions/checkout@v4 + + - name: Generate docs + run: make local-dox + + site-update: + name: Update github pages + needs: apidocs + if: github.repository_owner == 'Smithsonian' && (github.event_name == 'release' || contains(github.event.head_commit.message, 'site update')) + + runs-on: ubuntu-latest + steps: + + - name: Checkout smax-clib + uses: actions/checkout@v4 + with: + repository: Smithsonian/smax-clib + path: smax-clib + + - name: Check out xchange dependency + uses: actions/checkout@v4 + with: + repository: Smithsonian/xchange + path: xchange + + - name: Check out RedisX dependency + uses: actions/checkout@v4 + with: + repository: Smithsonian/redisx + path: redisx + + - name: Generate headless README for xchange + run: make -C xchange README-orig.md + + - name: Generate headless README for RedisX + run: make -C redisx README-orig.md + + - name: Generate xchange apidocs + uses: mattnotmitt/doxygen-action@v1.9.8 + with: + additional-packages: font-roboto + working-directory: ./xchange + + - name: Generate RedisX apidocs + uses: mattnotmitt/doxygen-action@v1.9.8 + with: + additional-packages: font-roboto + working-directory: ./redisx + + - name: Generate headless README for smax-clib + run: make -C redisx README-orig.md + + - name: Generate smax-clib apidocs + uses: mattnotmitt/doxygen-action@v1.9.8 + with: + additional-packages: font-roboto + working-directory: ./smax-clib + + - name: Checkout gh-pages + uses: actions/checkout@v4 + with: + ref: 'gh-pages' + path: site + + - name: Assert site/doc/ + run: mkdir -p site/doc + + - name: Copy README + run: | + echo 'CfA logo' > site/doc/README.md + echo '
' >> site/doc/README.md + cat redisx/README-orig.md >> site/doc/README.md + + - name: Copy CHANGELOG + run: cp redisx/CHANGELOG.md site/doc/ + + - name: Copy API documentation + run: cp -a redisx/apidoc site/ + + - name: Push to pages + run: | + cd site + git config --global user.email "$GITHUB_JOB+github-actions[bot]@users.noreply.github.com" + git config --global user.name "github-actions" + git add -A + git commit -m "[automated site update]" && git push || true + + + changelog-update: + name: Update CHANGELOG on github pages + if: github.repository_owner == 'Smithsonian' && contains(github.event.head_commit.message, 'changelog update') + + runs-on: ubuntu-latest + steps: + + - name: Checkout source + uses: actions/checkout@v4 + + - name: Checkout gh-pages + uses: actions/checkout@v4 + with: + ref: 'gh-pages' + path: site + + - name: Assert site/doc/ + run: mkdir -p site/doc + + - name: Copy CHANGELOG + run: cp CHANGELOG.md site/doc/ + + - name: Push to pages + run: | + cd site + git config --global user.email "$GITHUB_JOB+github-actions[bot]@users.noreply.github.com" + git config --global user.name "github-actions" + git add -A + git commit -m "[automated site update]" && git push || true +