Skip to content

Commit ecdcab6

Browse files
committed
CM-1053 - cycode cli
1 parent cb510bc commit ecdcab6

Some content is hidden

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

53 files changed

+2678
-1
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
on:
2+
push:
3+
branches: dev
4+
5+
jobs:
6+
main:
7+
runs-on: ubuntu-latest
8+
steps:
9+
-
10+
name: Checkout
11+
uses: actions/checkout@v2
12+
-
13+
name: Set up QEMU
14+
uses: docker/setup-qemu-action@v1
15+
-
16+
name: Set up Docker Buildx
17+
uses: docker/setup-buildx-action@v1
18+
-
19+
name: Login to DockerHub Registry
20+
env:
21+
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
22+
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
23+
run: echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USER" --password-stdin
24+
-
25+
name: Build and push
26+
id: docker_build
27+
uses: docker/build-push-action@v3
28+
with:
29+
context: .
30+
file: ./Dockerfile
31+
push: true
32+
tags: cycodehq/cycode_cli:dev
33+
-
34+
name: Image digest
35+
run: echo ${{ steps.docker_build.outputs.digest }}

.github/workflows/docker-image.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
on:
2+
workflow_dispatch:
3+
4+
jobs:
5+
main:
6+
runs-on: ubuntu-latest
7+
steps:
8+
-
9+
name: Checkout
10+
uses: actions/checkout@v2
11+
-
12+
name: Set up QEMU
13+
uses: docker/setup-qemu-action@v1
14+
-
15+
name: Set up Docker Buildx
16+
uses: docker/setup-buildx-action@v1
17+
-
18+
name: Login to DockerHub Registry
19+
env:
20+
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
21+
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
22+
run: echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USER" --password-stdin
23+
24+
- name: Bump version
25+
id: bump_version
26+
uses: anothrNick/github-tag-action@1.36.0
27+
env:
28+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
DEFAULT_BUMP: minor
30+
31+
-
32+
name: Build and push
33+
id: docker_build
34+
uses: docker/build-push-action@v3
35+
with:
36+
context: .
37+
file: ./Dockerfile
38+
push: true
39+
tags: cycodehq/cycode_cli:${{ steps.bump_version.outputs.new_tag }}
40+
-
41+
name: Image digest
42+
run: echo ${{ steps.docker_build.outputs.digest }}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# This workflows will upload a Python Package using Twine when a release is created
2+
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3+
4+
name: Upload Python Package
5+
6+
on:
7+
release:
8+
types: [created]
9+
10+
jobs:
11+
deploy:
12+
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Set up Python
18+
uses: actions/setup-python@v2
19+
with:
20+
python-version: '3.x'
21+
- name: Install dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
pip install setuptools wheel twine
25+
- name: Clean cache
26+
run: |
27+
python setup.py clean --all
28+
- name: Build and publish
29+
env:
30+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
31+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
32+
run: |
33+
python setup.py sdist bdist_wheel
34+
twine upload dist/*

.github/workflows/tests.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Unit Tests
2+
3+
on: [push]
4+
5+
jobs:
6+
deploy:
7+
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v2
12+
- name: Set up Python
13+
uses: actions/setup-python@v2
14+
with:
15+
python-version: '3.x'
16+
- name: Install dependencies
17+
run: |
18+
python -m pip install --upgrade pip
19+
pip install -r requirements.txt
20+
- name: Run Tests
21+
run: pytest

.pre-commit-hooks.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
- id: cycode
2+
name: Cycode pre commit defender
3+
language: python
4+
entry: cycode
5+
args: ['scan', 'pre_commit']

Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM python:3.8-buster as build-env
2+
WORKDIR /usr/cycode/app
3+
COPY . ./
4+
RUN python -m pip install --upgrade --no-cache-dir pip==22.0.4 setuptools==57.5.0 wheel==0.37.1
5+
RUN python3 setup.py sdist bdist_wheel
6+
7+
FROM python:3.8-slim-buster
8+
RUN apt-get update && apt-get install -y git=1:2.20.1-2+deb10u3 --no-install-recommends
9+
WORKDIR /usr/cycode/app
10+
COPY --from=build-env usr/cycode/app/dist ./
11+
RUN pip install --no-cache-dir cycode*.whl
12+
13+
RUN groupadd -r user && useradd -r -g user user
14+
15+
USER user
16+
17+
CMD ["cycode"]

LICENCE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 cycodehq-public
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)