Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
a149ace
Add work from other fork
Aug 7, 2024
30100cb
Merge pull request #1 from semgrep/yosef/automate
yosefAlsuhaibani Aug 7, 2024
19f654e
Hardcode configs + remove inc
Aug 8, 2024
e4921a8
adding remotes command
Aug 8, 2024
c96d086
going to version 2 of checkout
Aug 8, 2024
1683124
using version 4 of checkout
Aug 8, 2024
76e3ecf
using with submodules: true
Aug 8, 2024
ee02e43
remove fake reviwer`
Aug 8, 2024
a5d1cc9
Merge branch 'develop' of github.com:semgrep/test-pre-commit into dev…
Aug 8, 2024
8609929
add gh token
Aug 8, 2024
162bf76
aaa
Aug 8, 2024
bc83515
Add autoapprove bot
Aug 8, 2024
93b38c2
Remove approvals and merge from bump_version
Aug 8, 2024
bba5ac9
remove bogus reviewer
Aug 8, 2024
6fbe914
wack script
Aug 8, 2024
c9818c0
Fix bump ver
Aug 8, 2024
806ff2c
Restore state?
Aug 8, 2024
7338424
change name
Aug 8, 2024
008abcd
fix typo
Aug 8, 2024
19b4f52
Bump setup to 1.82.0
semgrep-ci[bot] Aug 8, 2024
5dc9f45
Merge pull request #13 from semgrep/gha/bump-version-1.82.0-103103432…
yosefAlsuhaibani Aug 8, 2024
8b2a0dc
Bump pre-commit yaml to 1.81.0 (#16)
semgrep-ci[bot] Aug 8, 2024
10535e7
Bump pre-commit yaml to 1.84.1 (#18)
semgrep-ci[bot] Aug 8, 2024
6c08f7f
Bump setup to 1.33.22 (#19)
semgrep-ci[bot] Aug 8, 2024
5e92b68
simplify workflow
Aug 8, 2024
e3964a3
Make 2nd step its own workflow
Aug 8, 2024
54fda03
Merge branch 'develop' of github.com:semgrep/test-pre-commit into dev…
Aug 8, 2024
5f8fa18
no dup name
Aug 8, 2024
eba186c
maybe fix error
Aug 8, 2024
2424aea
remove dup key
Aug 8, 2024
99b7521
don't hardcode bump yaml
Aug 8, 2024
e443ab6
Bump setup to 3.33.3 (#21)
semgrep-ci[bot] Aug 8, 2024
70b6ab9
Change trigger hook
Aug 8, 2024
d8034ff
Merge branch 'develop' of github.com:semgrep/test-pre-commit into dev…
Aug 8, 2024
79198a5
Bump setup to 2.22.2 (#22)
semgrep-ci[bot] Aug 8, 2024
00c4c38
remove dispatch
Aug 8, 2024
6b7ca85
try on:push
Aug 8, 2024
a97a710
Merge branch 'develop' of github.com:semgrep/test-pre-commit into dev…
Aug 8, 2024
2a113b0
Bump setup to 3.33.3 (#23)
semgrep-ci[bot] Aug 8, 2024
9c63b28
Merge branch 'develop' of github.com:semgrep/test-pre-commit into dev…
Aug 8, 2024
887de2a
Bump setup to 1.84.1 (#24)
semgrep-ci[bot] Aug 9, 2024
b30cd95
push a tag
Aug 9, 2024
dc18b5c
make sed portable
Aug 9, 2024
16cc089
reset version
Aug 9, 2024
620545c
commit all files
Aug 9, 2024
b98d1ce
Bump setup to 1.84.1 (#26)
semgrep-ci[bot] Aug 9, 2024
2ba84a4
Cooper edit
Aug 13, 2024
781573c
sync
Aug 14, 2024
bc41370
actually get token
Aug 14, 2024
362e121
perms
Aug 14, 2024
a581a6f
Bump setup to 1.84.0 (#29)
semgrep-ci[bot] Aug 14, 2024
bb4d00f
Don't negate?
Aug 14, 2024
3859b34
Merge branch 'develop' of github.com:semgrep/test-pre-commit into dev…
Aug 14, 2024
19e814e
Bump setup to 1.84.1 (#30)
semgrep-ci[bot] Aug 14, 2024
c361bad
escape properlly?
Aug 14, 2024
d5ef16e
Merge branch 'develop' of github.com:semgrep/test-pre-commit into dev…
Aug 14, 2024
8c9ba42
Bump setup to 1.84.0 (#31)
semgrep-ci[bot] Aug 14, 2024
f05315c
remove conditional
Aug 14, 2024
74b251c
Merge branch 'develop' of github.com:semgrep/test-pre-commit into dev…
Aug 14, 2024
36abb75
Bump setup to 1.84.1 (#32)
semgrep-ci[bot] Aug 14, 2024
1f31652
add back conditional
Aug 14, 2024
0af6900
Merge branch 'develop' of github.com:semgrep/test-pre-commit into dev…
Aug 14, 2024
bb07d58
fake file
Aug 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/autoapprove.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: github-actions auto-approve
on: pull_request_target

permissions:
pull-requests: write
contents: write

jobs:
approve-bot:
runs-on: ubuntu-latest
if: ${{ github.actor == 'github-actions' || github.actor == 'semgrep-ci[bot]'}}
steps:
- name: Enable auto-merge
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Approve
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82 changes: 82 additions & 0 deletions .github/workflows/bump_version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
jobs:
bump-version:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
pull-requests: write
checks: write
env:
NEW_SEMGREP_VERSION: ${{ github.event.inputs.version }}
steps:
- id: jwt
env:
EXPIRATION: 600
ISSUER: ${{ secrets.SEMGREP_CI_APP_ID }}
PRIVATE_KEY: ${{ secrets.SEMGREP_CI_APP_KEY }}
name: Get JWT for semgrep-ci GitHub App
uses: docker://public.ecr.aws/y9k7q4m1/devops/cicd:latest

- id: token
name: Get token for semgrep-ci GitHub App
run: |
TOKEN="$(curl -X POST \
-H "Authorization: Bearer ${{ steps.jwt.outputs.jwt }}" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/app/installations/${{ secrets.SEMGREP_CI_APP_INSTALLATION_ID }}/access_tokens" | \
jq -r .token)"
echo "::add-mask::$TOKEN"
echo "token=$TOKEN" >> $GITHUB_OUTPUT

- uses: actions/checkout@v4
with:
token: ${{ steps.token.outputs.token }}

- name: Bump version in this repo
run: scripts/bump-version.sh "${NEW_SEMGREP_VERSION}"

- name: Commit and push
id: commit
env:
BRANCH: "gha/bump-version-${{ github.event.inputs.version }}-${{ github.run_id }}-${{ github.run_attempt }}"
SUBJECT: "Bump setup to ${{ github.event.inputs.version }}"
run: |
git config user.name ${{ github.actor }}
git config user.email ${{ github.actor }}@users.noreply.github.com
git checkout -b $BRANCH
git commit -am "$SUBJECT"
git tag "v${NEW_SEMGREP_VERSION}" HEAD
git remote -vv
git push --set-upstream origin $BRANCH
git push origin tag "v$NEW_SEMGREP_VERSION"
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
echo "subject=$SUBJECT" >> $GITHUB_OUTPUT

- name: Create PR
id: open-pr
env:
SOURCE: "${{ steps.commit.outputs.branch }}"
TARGET: "${{ github.event.repository.default_branch }}"
TITLE: "chore: update pre-commit to semgrep ${{ inputs.version }}"
GITHUB_TOKEN: ${{ steps.token.outputs.token }}
VERSION: "${{ inputs.version }}"
run: |
# check if the branch already has a pull request open
if gh pr list --head ${SOURCE} | grep -vq "no pull requests"; then
# pull request already open
echo "pull request from SOURCE ${SOURCE} to TARGET ${TARGET} is already open";
echo "cancelling release"
exit 1
fi
# open new pull request with the body of from the local template.
res=$(gh pr create --title "${TITLE}" --body "Bump Semgrep Version to ${VERSION}" \
--base "${TARGET}" --head "${SOURCE}")

name: bump-version
on:
workflow_dispatch:
inputs:
version:
description: "Version of semgrep to use"
required: true
type: string
43 changes: 43 additions & 0 deletions .github/workflows/tag-version.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
jobs:
tag-version:
runs-on: ubuntu-latest
if: ${{contains(github.event.head_commit.message, 'Bump setup')}}
permissions:
id-token: write
contents: write
pull-requests: write
checks: write
steps:
- id: jwt
env:
EXPIRATION: 600
ISSUER: ${{ secrets.SEMGREP_CI_APP_ID }}
PRIVATE_KEY: ${{ secrets.SEMGREP_CI_APP_KEY }}
name: Get JWT for semgrep-ci GitHub App
uses: docker://public.ecr.aws/y9k7q4m1/devops/cicd:latest

- id: token
name: Get token for semgrep-ci GitHub App
run: |
TOKEN="$(curl -X POST \
-H "Authorization: Bearer ${{ steps.jwt.outputs.jwt }}" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/app/installations/${{ secrets.SEMGREP_CI_APP_INSTALLATION_ID }}/access_tokens" | \
jq -r .token)"
echo "::add-mask::$TOKEN"
echo "token=$TOKEN" >> $GITHUB_OUTPUT

- uses: actions/checkout@v4
with:
token: ${{ steps.token.outputs.token }}

- name: Bump version in this repo
env:
GITHUB_TOKEN: ${{ steps.token.outputs.token }}
run: scripts/tag-version.sh "${NEW_SEMGREP_VERSION}"

name: tag-version
on:
push:
branches:
- develop
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ default_stages: [manual]

repos:
- repo: https://github.com/semgrep/pre-commit
rev: 'v1.84.0'
rev: 'v1.84.1'
hooks:
- id: semgrep
name: Pre-commit semgrep
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ AppSec Platform][semgrep-platform], similar to `semgrep ci`, we provide the

```yaml
- repo: https://github.com/semgrep/pre-commit
rev: 'v1.84.0'
rev: 'v1.84.1'
hooks:
- id: semgrep-ci
```
Expand All @@ -29,7 +29,7 @@ committed with a specified config, skipping files with unknown extensions:

```yaml
- repo: https://github.com/semgrep/pre-commit
rev: 'v1.84.0'
rev: 'v1.84.1'
hooks:
- id: semgrep
# See https://semgrep.dev/explore to select a ruleset and copy its URL
Expand Down
1 change: 1 addition & 0 deletions a.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a
10 changes: 10 additions & 0 deletions scripts/bump-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
VERSION=$1
OLD_VERSION=$(grep -o 'version=\"[0-9.]*\"' setup.py | sed "s/version=\"\([0-9.]*\)\"/\1/")

# Do text substitution in setup.py & README.md
sed "s/$OLD_VERSION/$VERSION/" setup.py > tmp
mv tmp setup.py
sed "s/$OLD_VERSION/$VERSION/" README.md > tmp
mv tmp README.md
sed "s/$OLD_VERSION/$VERSION/" .pre-commit-config.yaml > tmp
mv tmp .pre-commit-config.yaml
4 changes: 4 additions & 0 deletions scripts/tag-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CURR_VERSION=$(grep -o 'version=\"[0-9.]*\"' setup.py | sed "s/version=\"\([0-9.]*\)\"/\1/")

git tag "v${CURR_VERSION}" HEAD
git push origin tag "v${CURR_VERSION}"
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name="semgrep_pre_commit_package",
version="1.84.0",
install_requires=["semgrep==1.84.0"],
version="1.84.1",
install_requires=["semgrep==1.84.1"],
packages=[],
)