Skip to content

Commit f89b321

Browse files
authored
Merge branch 'main' into typetracker-decorators
2 parents f1b0a81 + aa36556 commit f89b321

File tree

2,041 files changed

+145334
-121977
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,041 files changed

+145334
-121977
lines changed

.devcontainer/swift/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.236.0/containers/cpp/.devcontainer/base.Dockerfile
2+
3+
# [Choice] Debian / Ubuntu version (use Debian 11, Ubuntu 18.04/22.04 on local arm64/Apple Silicon): debian-11, debian-10, ubuntu-22.04, ubuntu-20.04, ubuntu-18.04
4+
FROM mcr.microsoft.com/vscode/devcontainers/cpp:0-ubuntu-22.04
5+
6+
USER root
7+
ADD root.sh /tmp/root.sh
8+
ADD update-codeql.sh /usr/local/bin/update-codeql
9+
RUN bash /tmp/root.sh && rm /tmp/root.sh

.devcontainer/swift/devcontainer.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"extensions": [
3+
"github.vscode-codeql",
4+
"hbenl.vscode-test-explorer",
5+
"ms-vscode.test-adapter-converter",
6+
"slevesque.vscode-zipexplorer",
7+
"ms-vscode.cpptools"
8+
],
9+
"settings": {
10+
"files.watcherExclude": {
11+
"**/target/**": true
12+
},
13+
"codeQL.runningQueries.memory": 2048
14+
},
15+
"build": {
16+
"dockerfile": "Dockerfile",
17+
},
18+
"runArgs": [
19+
"--cap-add=SYS_PTRACE",
20+
"--security-opt",
21+
"seccomp=unconfined"
22+
],
23+
"remoteUser": "vscode",
24+
"onCreateCommand": ".devcontainer/swift/user.sh"
25+
}

.devcontainer/swift/root.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
set -xe
2+
3+
BAZELISK_VERSION=v1.12.0
4+
BAZELISK_DOWNLOAD_SHA=6b0bcb2ea15bca16fffabe6fda75803440375354c085480fe361d2cbf32501db
5+
6+
apt-get update
7+
export DEBIAN_FRONTEND=noninteractive
8+
apt-get -y install --no-install-recommends \
9+
zlib1g-dev \
10+
uuid-dev \
11+
python3-distutils \
12+
python3-pip \
13+
bash-completion
14+
15+
# Install Bazel
16+
curl -fSsL -o /usr/local/bin/bazelisk https://github.com/bazelbuild/bazelisk/releases/download/${BAZELISK_VERSION}/bazelisk-linux-amd64
17+
echo "${BAZELISK_DOWNLOAD_SHA} */usr/local/bin/bazelisk" | sha256sum --check -
18+
chmod 0755 /usr/local/bin/bazelisk
19+
ln -s bazelisk /usr/local/bin/bazel
20+
21+
# install latest codeql
22+
update-codeql

.devcontainer/swift/update-codeql.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash -e
2+
3+
URL=https://github.com/github/codeql-cli-binaries/releases
4+
LATEST_VERSION=$(curl -L -s -H 'Accept: application/json' $URL/latest | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/')
5+
CURRENT_VERSION=v$(codeql version 2>/dev/null | sed -ne 's/.*release \([0-9.]*\)\./\1/p')
6+
if [[ $CURRENT_VERSION != $LATEST_VERSION ]]; then
7+
if [[ $UID != 0 ]]; then
8+
echo "update required, please run this script with sudo:"
9+
echo " sudo $0"
10+
exit 1
11+
fi
12+
ZIP=$(mktemp codeql.XXXX.zip)
13+
curl -fSqL -o $ZIP $URL/download/$LATEST_VERSION/codeql-linux64.zip
14+
unzip -q $ZIP -d /opt
15+
rm $ZIP
16+
ln -sf /opt/codeql/codeql /usr/local/bin/codeql
17+
echo installed version $LATEST_VERSION
18+
else
19+
echo current version $CURRENT_VERSION is up-to-date
20+
fi

.devcontainer/swift/user.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
set -xe
2+
3+
# add the workspace to the codeql search path
4+
mkdir -p /home/vscode/.config/codeql
5+
echo "--search-path /workspaces/codeql" > /home/vscode/.config/codeql/config
6+
7+
# create a swift extractor pack with the current state
8+
cd /workspaces/codeql
9+
bazel run swift/create-extractor-pack
10+
11+
#install and set up pre-commit
12+
python3 -m pip install pre-commit --no-warn-script-location
13+
$HOME/.local/bin/pre-commit install

.github/actions/fetch-codeql/action.yml

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,12 @@ description: Fetches the latest version of CodeQL
33
runs:
44
using: composite
55
steps:
6-
- name: Select platform - Linux
7-
if: runner.os == 'Linux'
8-
shell: bash
9-
run: echo "GA_CODEQL_CLI_PLATFORM=linux64" >> $GITHUB_ENV
10-
11-
- name: Select platform - MacOS
12-
if: runner.os == 'MacOS'
13-
shell: bash
14-
run: echo "GA_CODEQL_CLI_PLATFORM=osx64" >> $GITHUB_ENV
15-
166
- name: Fetch CodeQL
177
shell: bash
188
run: |
19-
LATEST=$(gh release list --repo https://github.com/github/codeql-cli-binaries | cut -f 1 | grep -v beta | sort --version-sort | tail -1)
20-
gh release download --repo https://github.com/github/codeql-cli-binaries --pattern codeql-$GA_CODEQL_CLI_PLATFORM.zip "$LATEST"
21-
unzip -q -d "${RUNNER_TEMP}" codeql-$GA_CODEQL_CLI_PLATFORM.zip
22-
echo "${RUNNER_TEMP}/codeql" >> "${GITHUB_PATH}"
9+
gh extension install github/gh-codeql
10+
gh codeql set-channel nightly
11+
gh codeql version
12+
gh codeql version --format=json | jq -r .unpackedLocation >> "${GITHUB_PATH}"
2313
env:
2414
GITHUB_TOKEN: ${{ github.token }}

.github/workflows/check-change-note.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010
- "*/ql/lib/**/*.qll"
1111
- "!**/experimental/**"
1212
- "!ql/**"
13+
- "!swift/**"
1314
- ".github/workflows/check-change-note.yml"
1415

1516
jobs:

.github/workflows/check-qldoc.yml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
paths:
66
- "*/ql/lib/**"
77
- .github/workflows/check-qldoc.yml
8+
- .github/actions/fetch-codeql/action.yml
89
branches:
910
- main
1011
- "rc/*"
@@ -14,18 +15,13 @@ jobs:
1415
runs-on: ubuntu-latest
1516

1617
steps:
17-
- name: Install CodeQL
18-
run: |
19-
gh extension install github/gh-codeql
20-
gh codeql set-channel nightly
21-
gh codeql version
22-
env:
23-
GITHUB_TOKEN: ${{ github.token }}
24-
2518
- uses: actions/checkout@v3
2619
with:
2720
fetch-depth: 2
2821

22+
- name: Install CodeQL
23+
uses: ./.github/actions/fetch-codeql
24+
2925
- name: Check QLdoc coverage
3026
shell: bash
3127
run: |
@@ -34,15 +30,15 @@ jobs:
3430
changed_lib_packs="$(git diff --name-only --diff-filter=ACMRT HEAD^ HEAD | { grep -Po '^(?!swift)[a-z]*/ql/lib' || true; } | sort -u)"
3531
for pack_dir in ${changed_lib_packs}; do
3632
lang="${pack_dir%/ql/lib}"
37-
gh codeql generate library-doc-coverage --output="${RUNNER_TEMP}/${lang}-current.txt" --dir="${pack_dir}"
33+
codeql generate library-doc-coverage --output="${RUNNER_TEMP}/${lang}-current.txt" --dir="${pack_dir}"
3834
done
3935
git checkout HEAD^
4036
for pack_dir in ${changed_lib_packs}; do
4137
# When we add a new language, pack_dir would not exist in HEAD^.
4238
# In this case the right thing to do is to skip the check.
4339
[[ ! -d "${pack_dir}" ]] && continue
4440
lang="${pack_dir%/ql/lib}"
45-
gh codeql generate library-doc-coverage --output="${RUNNER_TEMP}/${lang}-baseline.txt" --dir="${pack_dir}"
41+
codeql generate library-doc-coverage --output="${RUNNER_TEMP}/${lang}-baseline.txt" --dir="${pack_dir}"
4642
awk -F, '{gsub(/"/,""); if ($4==0 && $6=="public") print "\""$3"\"" }' "${RUNNER_TEMP}/${lang}-current.txt" | sort -u > "${RUNNER_TEMP}/current-undocumented.txt"
4743
awk -F, '{gsub(/"/,""); if ($4==0 && $6=="public") print "\""$3"\"" }' "${RUNNER_TEMP}/${lang}-baseline.txt" | sort -u > "${RUNNER_TEMP}/baseline-undocumented.txt"
4844
UNDOCUMENTED="$(grep -f <(comm -13 "${RUNNER_TEMP}/baseline-undocumented.txt" "${RUNNER_TEMP}/current-undocumented.txt") "${RUNNER_TEMP}/${lang}-current.txt" || true)"

.github/workflows/csv-coverage-metrics.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ on:
1212
- main
1313
paths:
1414
- ".github/workflows/csv-coverage-metrics.yml"
15+
- ".github/actions/fetch-codeql/action.yml"
1516

1617
jobs:
1718
publish-java:

.github/workflows/csv-coverage-pr-artifacts.yml

Lines changed: 80 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,20 @@ name: Check framework coverage changes
33
on:
44
pull_request:
55
paths:
6-
- '.github/workflows/csv-coverage-pr-comment.yml'
7-
- '*/ql/src/**/*.ql'
8-
- '*/ql/src/**/*.qll'
9-
- '*/ql/lib/**/*.ql'
10-
- '*/ql/lib/**/*.qll'
11-
- 'misc/scripts/library-coverage/*.py'
6+
- ".github/workflows/csv-coverage-pr-comment.yml"
7+
- ".github/workflows/csv-coverage-pr-artifacts.yml"
8+
- ".github/actions/fetch-codeql/action.yml"
9+
- "*/ql/src/**/*.ql"
10+
- "*/ql/src/**/*.qll"
11+
- "*/ql/lib/**/*.ql"
12+
- "*/ql/lib/**/*.qll"
13+
- "misc/scripts/library-coverage/*.py"
1214
# input data files
13-
- '*/documentation/library-coverage/cwe-sink.csv'
14-
- '*/documentation/library-coverage/frameworks.csv'
15+
- "*/documentation/library-coverage/cwe-sink.csv"
16+
- "*/documentation/library-coverage/frameworks.csv"
1517
branches:
1618
- main
17-
- 'rc/*'
19+
- "rc/*"
1820

1921
jobs:
2022
generate:
@@ -23,77 +25,72 @@ jobs:
2325
runs-on: ubuntu-latest
2426

2527
steps:
26-
- name: Dump GitHub context
27-
env:
28-
GITHUB_CONTEXT: ${{ toJSON(github.event) }}
29-
run: echo "$GITHUB_CONTEXT"
30-
- name: Clone self (github/codeql) - MERGE
31-
uses: actions/checkout@v3
32-
with:
33-
path: merge
34-
- name: Clone self (github/codeql) - BASE
35-
uses: actions/checkout@v3
36-
with:
37-
fetch-depth: 2
38-
path: base
39-
- run: |
40-
git checkout HEAD^1
41-
git log -1 --format='%H'
42-
working-directory: base
43-
- name: Set up Python 3.8
44-
uses: actions/setup-python@v4
45-
with:
46-
python-version: 3.8
47-
- name: Download CodeQL CLI
48-
env:
49-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50-
run: |
51-
gh release download --repo "github/codeql-cli-binaries" --pattern "codeql-linux64.zip"
52-
- name: Unzip CodeQL CLI
53-
run: unzip -d codeql-cli codeql-linux64.zip
54-
- name: Generate CSV files on merge commit of the PR
55-
run: |
56-
echo "Running generator on merge"
57-
PATH="$PATH:codeql-cli/codeql" python merge/misc/scripts/library-coverage/generate-report.py ci merge merge
58-
mkdir out_merge
59-
cp framework-coverage-*.csv out_merge/
60-
cp framework-coverage-*.rst out_merge/
61-
- name: Generate CSV files on base commit of the PR
62-
run: |
63-
echo "Running generator on base"
64-
PATH="$PATH:codeql-cli/codeql" python base/misc/scripts/library-coverage/generate-report.py ci base base
65-
mkdir out_base
66-
cp framework-coverage-*.csv out_base/
67-
cp framework-coverage-*.rst out_base/
68-
- name: Generate diff of coverage reports
69-
run: |
70-
python base/misc/scripts/library-coverage/compare-folders.py out_base out_merge comparison.md
71-
- name: Upload CSV package list
72-
uses: actions/upload-artifact@v3
73-
with:
74-
name: csv-framework-coverage-merge
75-
path: |
76-
out_merge/framework-coverage-*.csv
77-
out_merge/framework-coverage-*.rst
78-
- name: Upload CSV package list
79-
uses: actions/upload-artifact@v3
80-
with:
81-
name: csv-framework-coverage-base
82-
path: |
83-
out_base/framework-coverage-*.csv
84-
out_base/framework-coverage-*.rst
85-
- name: Upload comparison results
86-
uses: actions/upload-artifact@v3
87-
with:
88-
name: comparison
89-
path: |
90-
comparison.md
91-
- name: Save PR number
92-
run: |
93-
mkdir -p pr
94-
echo ${{ github.event.pull_request.number }} > pr/NR
95-
- name: Upload PR number
96-
uses: actions/upload-artifact@v3
97-
with:
98-
name: pr
99-
path: pr/
28+
- name: Dump GitHub context
29+
env:
30+
GITHUB_CONTEXT: ${{ toJSON(github.event) }}
31+
run: echo "$GITHUB_CONTEXT"
32+
- name: Clone self (github/codeql) - MERGE
33+
uses: actions/checkout@v3
34+
with:
35+
path: merge
36+
- name: Clone self (github/codeql) - BASE
37+
uses: actions/checkout@v3
38+
with:
39+
fetch-depth: 2
40+
path: base
41+
- run: |
42+
git checkout HEAD^1
43+
git log -1 --format='%H'
44+
working-directory: base
45+
- name: Set up Python 3.8
46+
uses: actions/setup-python@v4
47+
with:
48+
python-version: 3.8
49+
- name: Download CodeQL CLI
50+
uses: ./merge/.github/actions/fetch-codeql
51+
- name: Generate CSV files on merge commit of the PR
52+
run: |
53+
echo "Running generator on merge"
54+
python merge/misc/scripts/library-coverage/generate-report.py ci merge merge
55+
mkdir out_merge
56+
cp framework-coverage-*.csv out_merge/
57+
cp framework-coverage-*.rst out_merge/
58+
- name: Generate CSV files on base commit of the PR
59+
run: |
60+
echo "Running generator on base"
61+
python base/misc/scripts/library-coverage/generate-report.py ci base base
62+
mkdir out_base
63+
cp framework-coverage-*.csv out_base/
64+
cp framework-coverage-*.rst out_base/
65+
- name: Generate diff of coverage reports
66+
run: |
67+
python base/misc/scripts/library-coverage/compare-folders.py out_base out_merge comparison.md
68+
- name: Upload CSV package list
69+
uses: actions/upload-artifact@v3
70+
with:
71+
name: csv-framework-coverage-merge
72+
path: |
73+
out_merge/framework-coverage-*.csv
74+
out_merge/framework-coverage-*.rst
75+
- name: Upload CSV package list
76+
uses: actions/upload-artifact@v3
77+
with:
78+
name: csv-framework-coverage-base
79+
path: |
80+
out_base/framework-coverage-*.csv
81+
out_base/framework-coverage-*.rst
82+
- name: Upload comparison results
83+
uses: actions/upload-artifact@v3
84+
with:
85+
name: comparison
86+
path: |
87+
comparison.md
88+
- name: Save PR number
89+
run: |
90+
mkdir -p pr
91+
echo ${{ github.event.pull_request.number }} > pr/NR
92+
- name: Upload PR number
93+
uses: actions/upload-artifact@v3
94+
with:
95+
name: pr
96+
path: pr/

0 commit comments

Comments
 (0)