|
| 1 | +name: Collect database stats |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + paths: |
| 7 | + - ql/src/ruby.dbscheme |
| 8 | + pull_request: |
| 9 | + branches: [main] |
| 10 | + paths: |
| 11 | + - ql/src/ruby.dbscheme |
| 12 | + |
| 13 | +jobs: |
| 14 | + measure: |
| 15 | + strategy: |
| 16 | + fail-fast: false |
| 17 | + matrix: |
| 18 | + repo: [rails/rails, discourse/discourse, spree/spree] |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v2 |
| 22 | + |
| 23 | + - name: Fetch CodeQL |
| 24 | + run: | |
| 25 | + gh release download --repo https://github.com/github/codeql-cli-binaries --pattern codeql-linux64.zip |
| 26 | + unzip -q codeql-linux64.zip |
| 27 | + env: |
| 28 | + GITHUB_TOKEN: ${{ github.token }} |
| 29 | + - uses: actions/cache@v2 |
| 30 | + with: |
| 31 | + path: | |
| 32 | + ~/.cargo/registry |
| 33 | + ~/.cargo/git |
| 34 | + target |
| 35 | + key: ${{ runner.os }}-qltest-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 36 | + - name: Build Extractor |
| 37 | + run: env "PATH=$PATH:${{ github.workspace }}/codeql" ./create-extractor-pack.sh |
| 38 | + |
| 39 | + - name: Checkout ${{ matrix.repo }} |
| 40 | + uses: actions/checkout@v2 |
| 41 | + with: |
| 42 | + repository: ${{ matrix.repo }} |
| 43 | + path: ${{ github.workspace }}/repo |
| 44 | + - name: Create database |
| 45 | + run: | |
| 46 | + codeql/codeql database create \ |
| 47 | + --search-path "${{ github.workspace }}" \ |
| 48 | + --language ruby --source-root "${{ github.workspace }}/repo" \ |
| 49 | + "${{ runner.temp }}/database" |
| 50 | + - name: Measure database |
| 51 | + run: | |
| 52 | + mkdir -p "stats/${{ matrix.repo }}" |
| 53 | + codeql/codeql dataset measure --output "stats/${{ matrix.repo }}/stats.xml" "${{ runner.temp }}/database/db-ruby" |
| 54 | + - uses: actions/upload-artifact@v2 |
| 55 | + with: |
| 56 | + name: measurements |
| 57 | + path: stats |
| 58 | + retention-days: 1 |
| 59 | + |
| 60 | + merge: |
| 61 | + runs-on: ubuntu-latest |
| 62 | + needs: measure |
| 63 | + steps: |
| 64 | + - uses: actions/checkout@v2 |
| 65 | + - uses: actions/download-artifact@v2 |
| 66 | + with: |
| 67 | + name: measurements |
| 68 | + path: stats |
| 69 | + - run: | |
| 70 | + python -m pip install --user lxml |
| 71 | + find stats -name 'stats.xml' | sort | xargs python scripts/merge_stats.py --output ql/src/ruby.dbscheme.stats --normalise tokeninfo |
| 72 | + - uses: actions/upload-artifact@v2 |
| 73 | + with: |
| 74 | + name: ruby.dbscheme.stats |
| 75 | + path: ql/src/ruby.dbscheme.stats |
0 commit comments