Skip to content

Commit 2c1b7c2

Browse files
authored
Add template for running D2D on project build and source archive (#30)
Signed-off-by: Keshav Priyadarshi <[email protected]>
1 parent 5641047 commit 2c1b7c2

File tree

3 files changed

+112
-1
lines changed

3 files changed

+112
-1
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Run D2D on build and source archives
2+
on:
3+
workflow_call:
4+
inputs:
5+
artifact-name:
6+
description: "Artifact containing the build archive"
7+
required: true
8+
type: string
9+
steps:
10+
description: "Comma separated D2D steps to run"
11+
required: false
12+
type: string
13+
repository:
14+
description: "Project's repository. Defaults to workflow's repository."
15+
required: false
16+
type: string
17+
18+
jobs:
19+
run-d2d-pipeline:
20+
runs-on: 'ubuntu-latest'
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
with:
25+
repository: ${{ inputs.repository || github.repository }}
26+
27+
- name: Download build artifact
28+
uses: actions/download-artifact@v4
29+
with:
30+
name: ${{ inputs['artifact-name'] }}
31+
path: ../scancode-inputs/
32+
33+
- name: Prepare D2D inputs
34+
shell: bash
35+
run: |
36+
for file in ../scancode-inputs/*; do
37+
base=$(basename "$file")
38+
mv "$file" "../scancode-inputs/to_$base"
39+
done
40+
git archive --format=tar.gz -o ../scancode-inputs/from.tar.gz HEAD
41+
42+
- name: Run D2D pipeline
43+
uses: aboutcode-org/scancode-action@beta
44+
with:
45+
pipelines: ${{ inputs.steps && format('map_deploy_to_develop:%s', inputs.steps) || 'map_deploy_to_develop' }}
46+
inputs-path: ../scancode-inputs
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Run source to binary mapping on boolean.py
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- main
9+
10+
jobs:
11+
build-python-wheel:
12+
name: Build python wheel
13+
runs-on: ubuntu-24.04
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
repository: bastikr/boolean.py
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: 3.12
24+
25+
- name: Install pypa/build and twine
26+
run: python -m pip install --user --upgrade build twine packaging pip setuptools
27+
28+
- name: Build a binary wheel
29+
run: python -m build --wheel --outdir dist/
30+
31+
- name: Upload wheel
32+
uses: actions/upload-artifact@v4
33+
with:
34+
name: wheel_archives
35+
path: dist/*.whl
36+
37+
map-source-binary:
38+
name: Generate source to binary mapping
39+
needs: build-python-wheel
40+
uses: ./.github/workflows/map-deploy-to-develop-template.yml
41+
with:
42+
artifact-name: wheel_archives
43+
repository: bastikr/boolean.py
44+
steps: "python"

README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ from your **GitHub Workflows**.
2525
- [Check for compliance issues](#check-for-compliance-issues)
2626
- [Define a custom project name](#define-a-custom-project-name)
2727
- [Install ScanCode.io from a repository branch](#install-scancodeio-from-a-repository-branch)
28-
- [Where does the scan results go?](#where-does-the-scan-results-go)
28+
- [Run source to binary mapping](#run-source-to-binary-mapping)
29+
- [Where does the scan results go?](#where-are-the-scan-results)
2930

3031
## Usage
3132

@@ -226,6 +227,26 @@ Activate this behavior by enabling `check-compliance` and setting
226227
scancodeio-repo-branch: "main"
227228
```
228229

230+
### Run source to binary mapping
231+
232+
Use this [workflow template](.github/workflows/map-deploy-to-develop-template.yml) for validating the integrity of open-source binary. It compares a project’s binary to its source code. Workflow will generate mapping between compiled binary and its original source code, which helps in spotting any malicious, unexpected, or otherwise undesirable code that may have made its way into the final binary.
233+
234+
#### To use follow these steps:
235+
236+
1. In your workflow add job to build binary and upload it as a GitHub actions artifact.
237+
2. Now add a second job to run source binary mapping using [template](.github/workflows/map-deploy-to-develop-template.yml).
238+
```yaml
239+
map-source-binary:
240+
needs: # Job id from step 1
241+
uses: aboutcode-org/scancode-action/.github/workflows/map-deploy-to-develop-template.yml
242+
with:
243+
artifact-name: # Label of uploaded artifact from step 1
244+
steps: "python,java" # Comma separated optional steps. See https://scancodeio.readthedocs.io/en/latest/built-in-pipelines.html#map-deploy-to-develop
245+
```
246+
247+
See an end-to-end working example for a python project [here](.github/workflows/map-source-binary-boolean-py.yml)
248+
249+
229250
## Where are the Scan Results?
230251

231252
Upon completion of the workflow, you can **find the scan results** in the dedicated

0 commit comments

Comments
 (0)