mirror of
https://github.com/github/codeql.git
synced 2026-03-05 23:26:51 +01:00
133 lines
4.1 KiB
YAML
133 lines
4.1 KiB
YAML
name: Build codeql-ql-pack
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
workflow_call:
|
|
inputs:
|
|
os:
|
|
description: A JSON array string of (fixed) operating systems to build for, e.g. '["ubuntu-latest", "macos-latest", "windows-latest"]'
|
|
required: false
|
|
type: string
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
|
|
jobs:
|
|
queries:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: Find codeql
|
|
id: find-codeql
|
|
uses: github/codeql-action/init@esbena/ql
|
|
with:
|
|
languages: javascript # does not matter
|
|
- name: Build query pack
|
|
run: |
|
|
cd ql/src
|
|
"${CODEQL}" pack create
|
|
cd .codeql/pack/codeql/ql-all/0.0.0
|
|
zip "${PACKZIP}" -r .
|
|
env:
|
|
CODEQL: ${{ steps.find-codeql.outputs.codeql-path }}
|
|
PACKZIP: ${{ runner.temp }}/query-pack.zip
|
|
- name: Upload query pack
|
|
uses: actions/upload-artifact@v2
|
|
with:
|
|
name: query-pack-zip
|
|
path: ${{ runner.temp }}/query-pack.zip
|
|
|
|
extractors:
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: ${{ fromJson(inputs.os || '["ubuntu-latest", "macos-latest", "windows-latest"]') }}
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: Install GNU tar
|
|
if: runner.os == 'macOS'
|
|
run: |
|
|
brew install gnu-tar
|
|
echo "/usr/local/opt/gnu-tar/libexec/gnubin" >> $GITHUB_PATH
|
|
- uses: actions/cache@v2
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
target
|
|
key: ${{ runner.os }}-rust-cargo-${{ hashFiles('**/Cargo.lock') }}
|
|
- name: Check formatting
|
|
run: cargo fmt --all -- --check
|
|
- name: Build
|
|
run: cargo build --verbose
|
|
- name: Run tests
|
|
run: cargo test --verbose
|
|
- name: Release build
|
|
run: cargo build --release
|
|
- name: Generate dbscheme
|
|
if: ${{ matrix.os == 'ubuntu-latest' }}
|
|
run: target/release/ql-generator --dbscheme ql/src/ql.dbscheme --library ql/src/codeql_ql/ast/internal/TreeSitter.qll
|
|
- uses: actions/upload-artifact@v2
|
|
with:
|
|
name: extractor-${{ matrix.os }}
|
|
path: |
|
|
target/release/ql-extractor
|
|
target/release/ql-extractor.exe
|
|
retention-days: 1
|
|
package:
|
|
runs-on: ubuntu-latest
|
|
|
|
needs:
|
|
- extractors
|
|
- queries
|
|
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- uses: actions/download-artifact@v2
|
|
with:
|
|
name: query-pack-zip
|
|
path: query-pack-zip
|
|
- uses: actions/download-artifact@v2
|
|
if: ${{ contains(fromJson(inputs.os || '["ubuntu-latest", "macos-latest", "windows-latest"]'), 'ubuntu-latest') }}
|
|
with:
|
|
name: extractor-ubuntu-latest
|
|
path: linux64
|
|
- uses: actions/download-artifact@v2
|
|
if: ${{ contains(fromJson(inputs.os || '["ubuntu-latest", "macos-latest", "windows-latest"]'), 'windows-latest') }}
|
|
with:
|
|
name: extractor-windows-latest
|
|
path: win64
|
|
- uses: actions/download-artifact@v2
|
|
if: ${{ contains(fromJson(inputs.os || '["ubuntu-latest", "macos-latest", "windows-latest"]'), 'macos-latest') }}
|
|
with:
|
|
name: extractor-macos-latest
|
|
path: osx64
|
|
- run: |
|
|
unzip query-pack-zip/*.zip -d pack
|
|
cp -r codeql-extractor.yml tools ql/src/ql.dbscheme.stats pack/
|
|
mkdir -p pack/tools/{linux64,osx64,win64}
|
|
if [[ -f linux64/ql-extractor ]]; then
|
|
cp linux64/ql-extractor pack/tools/linux64/extractor
|
|
chmod +x pack/tools/linux64/extractor
|
|
fi
|
|
if [[ -f osx64/ql-extractor ]]; then
|
|
cp osx64/ql-extractor pack/tools/osx64/extractor
|
|
chmod +x pack/tools/osx64/extractor
|
|
fi
|
|
if [[ -f win64/ql-extractor.exe ]]; then
|
|
cp win64/ql-extractor.exe pack/tools/win64/extractor
|
|
fi
|
|
cd pack
|
|
zip -rq ../codeql-ql.zip .
|
|
- uses: actions/upload-artifact@v2
|
|
with:
|
|
name: codeql-ql-pack
|
|
path: codeql-ql.zip
|
|
retention-days: 1
|