Skip to content

Commit b33f73f

Browse files
committed
build: testing github action works using push trigger
Signed-off-by: Carl Flottmann <carl.flottmann@oracle.com>
1 parent 4ead933 commit b33f73f

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

.github/workflows/build_semgrep_wheel.yaml

+29-29
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
name: Build Semgrep Wheel Artifact
55

6-
on: workflow_dispatch
6+
on: [push, workflow_dispatch]
77

88
permissions:
99
contents: read
@@ -12,44 +12,44 @@ jobs:
1212
build-semgrep-wheel:
1313
name: Build Semgrep wheel
1414
runs-on: ubuntu-latest
15+
permissions:
16+
packages: write # to push the docker image
1517
defaults:
1618
run:
1719
shell: bash
1820

1921
steps:
20-
- name: Install git # for cloning Semgrep repository
21-
run: |
22-
sudo apt-get install git
23-
24-
- name: Clone Semgrep v1.113.0 repository
25-
run: |
26-
git init
27-
git remote add origin https://github.com/semgrep/semgrep.git
28-
git fetch --depth 1 origin 4729a05d24bf9cee8face447e8a6d418037d61d8
29-
git checkout FETCH_HEAD
30-
git submodule update --init --recursive --depth 1
22+
# To update the semgrep version, please apply the following changes:
23+
# - change the version tag in the 'name' description
24+
# - change the 'ref' field to use the commit hash of that tag
25+
- name: Check out Semgrep v1.113.0 repository
26+
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
27+
with:
28+
repository: semgrep/semgrep.git
29+
ref: 4729a05d24bf9cee8face447e8a6d418037d61d8 # v1.113.0
30+
fetch-depth: 1 # only need most recent commits to this tag
31+
submodules: recursive # semgrep uses many of their own ocaml submodules, which are required to build
3132

3233
- name: Build wheel through docker
34+
# we build to the 'semgrep-wheel' target as we don't need the performance testing, and want to extract the wheel
3335
run: |
3436
docker build --target semgrep-wheel -t semgrep .
3537
docker create --name temp semgrep
36-
mkdir -p dist/
37-
docker cp temp:/semgrep/cli/dist/ dist/
38+
mkdir -p wheels/
39+
docker cp temp:/semgrep/cli/dist/. wheels/
3840
docker container rm temp
3941
40-
- name: Get wheel name
42+
# - name: Log in to GitHub Container Registry
43+
# run: docker login ghcr.io --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }}
44+
45+
# The manylinux image will be a static binary built using musl, suitable for Oracle linux
46+
- name: Build and push semgrep wheel image
4147
run: |
42-
WHEELS=($(find ./dist -type f -name "*manylinux*.whl"))
43-
if [ "${WHEELS[@]}" -ne 1]; then
44-
echo "Expected a single wheel file built by semgrep dockerfile"
45-
exit 1
46-
fi
47-
echo "WHEEL_PATH=${WHEELS[0]}" >> "$GITHUB_ENV"
48-
49-
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
50-
with:
51-
name: semgrep_wheel_manylinux.whl
52-
path: ${{ env.WHEEL_PATH }}
53-
if-no-files-found: error
54-
compression-level: 0 # don't compress the wheel file
55-
retention-days: 90 # uploaded wheel valid for 90 days, before workflow must be run again
48+
cd wheels
49+
WHEEL=$(find . -type f -name 'semgrep-*manylinux*.whl')
50+
echo "FROM scratch
51+
COPY ${WHEEL} /semgrep_wheel.whl" >> Dockerfile.semgrep
52+
docker build -t ghcr.io/macaron/macaron-deps:latest -f Dockerfile.semgrep .
53+
54+
55+
# docker push ghcr.io/macaron/macaron-deps:latest

0 commit comments

Comments
 (0)