-
Notifications
You must be signed in to change notification settings - Fork 2
SECURITY-47: Add GHA workflows #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8931e03
d48f48e
fd5d1aa
b5494fe
d148f61
d0b0657
9d09a8f
0d117dc
decde53
3275e09
9b4eeb9
945b204
f516823
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| name: "Code scanning - action" | ||
|
|
||
| on: | ||
| push: | ||
| pull_request: | ||
| schedule: | ||
| - cron: '0 19 * * 0' | ||
|
|
||
| jobs: | ||
| CodeQL-Build: | ||
|
|
||
| # CodeQL runs on ubuntu-latest and windows-latest | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| # We must fetch at least the immediate parents so that if this is | ||
| # a pull request then we can checkout the head. | ||
| fetch-depth: 2 | ||
|
|
||
| # If this run was triggered by a pull request event, then checkout | ||
| # the head of the pull request instead of the merge commit. | ||
| - run: git checkout HEAD^2 | ||
| if: ${{ github.event_name == 'pull_request' }} | ||
|
|
||
| # Initializes the CodeQL tools for scanning. | ||
| - name: Initialize CodeQL | ||
| uses: github/codeql-action/init@v3 | ||
| # Override language selection by uncommenting this and choosing your languages | ||
| # with: | ||
| # languages: go, javascript, csharp, python, cpp, java | ||
|
|
||
| # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). | ||
| # If this step fails, then you should remove it and run the build manually (see below) | ||
| - name: Autobuild | ||
| uses: github/codeql-action/autobuild@v3 | ||
|
|
||
| # ℹ️ Command-line programs to run using the OS shell. | ||
| # 📚 https://git.io/JvXDl | ||
|
|
||
| # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines | ||
| # and modify them (or add more) to build your code if your project | ||
| # uses a compiled language | ||
|
|
||
| #- run: | | ||
| # make bootstrap | ||
| # make release | ||
|
|
||
| - name: Perform CodeQL Analysis | ||
| uses: github/codeql-action/analyze@v3 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| version: 2 | ||
| updates: | ||
|
|
||
| # Docker | ||
| - package-ecosystem: docker | ||
| directory: "/" | ||
| schedule: | ||
| interval: "monthly" | ||
| open-pull-requests-limit: 25 | ||
|
|
||
| # Python | ||
| - package-ecosystem: "pip" # See documentation for possible values | ||
| directory: "/" # Location of package manifests | ||
| schedule: | ||
| interval: "monthly" | ||
| open-pull-requests-limit: 25 | ||
|
|
||
| # GitHub Actions | ||
| - package-ecosystem: "github-actions" | ||
| directory: ".github/workflows" | ||
| schedule: | ||
| interval: "monthly" | ||
| open-pull-requests-limit: 25 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| --- | ||
| name: Manual Build & Push | ||
| on: | ||
| workflow_dispatch: | ||
| jobs: | ||
| build-push: | ||
| uses: kbase/.github/.github/workflows/reusable_build-push.yml@main | ||
| with: | ||
| name: '${{ github.event.repository.name }}-develop' | ||
| tags: br-${{ github.ref_name }} | ||
| secrets: inherit |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| --- | ||
| name: Pull Request Build, Tag, & Push | ||
| on: | ||
| pull_request: | ||
| branches: | ||
| - develop | ||
| - main | ||
| - master | ||
| types: | ||
| - opened | ||
| - reopened | ||
| - synchronize | ||
| - closed | ||
| jobs: | ||
| build-develop-open: | ||
| if: github.base_ref == 'develop' && github.event.pull_request.merged == false | ||
| uses: kbase/.github/.github/workflows/reusable_build.yml@main | ||
| secrets: inherit | ||
| build-develop-merge: | ||
| if: github.base_ref == 'develop' && github.event.pull_request.merged == true | ||
| uses: kbase/.github/.github/workflows/reusable_build-push.yml@main | ||
| with: | ||
| name: '${{ github.event.repository.name }}-develop' | ||
| tags: pr-${{ github.event.number }},latest | ||
| secrets: inherit | ||
| build-main-open: | ||
| if: (github.base_ref == 'main' || github.base_ref == 'master') && github.event.pull_request.merged == false | ||
| uses: kbase/.github/.github/workflows/reusable_build-push.yml@main | ||
| with: | ||
| name: '${{ github.event.repository.name }}' | ||
| tags: pr-${{ github.event.number }} | ||
| secrets: inherit | ||
| build-main-merge: | ||
| if: (github.base_ref == 'main' || github.base_ref == 'master') && github.event.pull_request.merged == true | ||
| uses: kbase/.github/.github/workflows/reusable_build-push.yml@main | ||
| with: | ||
| name: '${{ github.event.repository.name }}' | ||
| tags: pr-${{ github.event.number }},latest-rc | ||
| secrets: inherit | ||
| trivy-scans: | ||
| if: (github.base_ref == 'develop' || github.base_ref == 'main' || github.base_ref == 'master' ) && github.event.pull_request.merged == false | ||
| uses: kbase/.github/.github/workflows/reusable_trivy-scans.yml@main | ||
| secrets: inherit |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| --- | ||
| name: Release - Build & Push Image | ||
| on: | ||
| release: | ||
| branches: | ||
| - main | ||
| - master | ||
| types: [ published ] | ||
| jobs: | ||
| check-source-branch: | ||
| uses: kbase/.github/.github/workflows/reusable_validate-branch.yml@main | ||
| with: | ||
| build_branch: '${{ github.event.release.target_commitish }}' | ||
| validate-release-tag: | ||
| needs: check-source-branch | ||
| uses: kbase/.github/.github/workflows/reusable_validate-release-tag.yml@main | ||
| with: | ||
| release_tag: '${{ github.event.release.tag_name }}' | ||
| build-push: | ||
| needs: validate-release-tag | ||
| uses: kbase/.github/.github/workflows/reusable_build-push.yml@main | ||
| with: | ||
| name: '${{ github.event.repository.name }}' | ||
| tags: '${{ github.event.release.tag_name }},latest' | ||
| secrets: inherit |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| name: KBase File Cache Server test | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: | ||
| - opened | ||
| - reopened | ||
| - synchronize | ||
| - ready_for_review | ||
| push: | ||
| # run workflow when merging to main or develop | ||
| branches: | ||
| - main | ||
| - master | ||
| - develop | ||
|
|
||
| jobs: | ||
| file_cache_server_tests: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Repo checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: 3.9.19 | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install -r requirements.txt | ||
| pip install -r dev-requirements.txt | ||
|
Comment on lines
+33
to
+34
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you make an issue to upgrade to pipenv or something later?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| - name: Run tests | ||
| shell: bash | ||
| run: | | ||
| docker compose up -d | ||
| sleep 10 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yuck but ok, that's what's in travis.yml |
||
| make test | ||
|
|
||
| - name: Upload coverage to Codecov | ||
| uses: codecov/codecov-action@v5 | ||
| with: | ||
| token: ${{ secrets.CODECOV_TOKEN }} | ||
| fail_ci_if_error: true | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| FROM python:3.7-slim | ||
| FROM python:3.9.19-slim | ||
|
|
||
| ARG DEVELOPMENT | ||
| ARG BUILD_DATE | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| .PHONY: test stress-test | ||
|
|
||
| test: | ||
| docker-compose run web sh scripts/run_tests.sh | ||
| docker compose run web sh scripts/run_tests.sh | ||
|
|
||
| stress-test: | ||
| docker-compose run web sh -c "python -m unittest src/test/test_server_stress.py" | ||
| docker compose run web sh -c "python -m unittest src/test/test_server_stress.py" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 0.1.0 | ||
| 0.1.1 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| mypy==0.800 | ||
| bandit==1.7.0 | ||
| mccabe==0.6.1 | ||
| flake8==3.8.4 | ||
| mccabe==0.7.0 | ||
| flake8==5.0.4 | ||
| grequests==0.6.0 | ||
| coverage==5.4 | ||
| pytest==7.4.0 | ||
| pytest-cov==4.1.0 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,11 @@ | ||
| minio==7.0.2 | ||
| Flask==1.1.2 | ||
| flask==2.0.3 | ||
| gunicorn==20.0.4 | ||
| gevent==21.1.2 | ||
| simplejson==3.17.2 | ||
| python-dotenv==0.15.0 | ||
| requests==2.25.1 | ||
| docopt==0.6.2 | ||
| Jinja2==3.0 | ||
| MarkupSafe==2.0.0 | ||
| werkzeug==2.0.3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why such a low version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the other repos where we have done the Mongo upgrade are using this version. I'm trying to make it consistent here. If you prefer 3.11.x, that's fine. I don't have a strong opinion on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember off the top of my head, but I think there were specific reasons why we used lower versions. If it's just as easy to go to a higher version go ahead and do it. Also make sure the test version and build version are aligned
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we change the build version to 3.9.19, 19/39 tests would fail. If we want to git them fixed, I prefer to do them in the next PR. If we upgrade python version to 3.11.x, we need more dep changes because of build error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just leave it as 3.9 in that case, don't bother upgrading for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, so we need to create an issue for that as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, it needs to be updated in the build in this PR - the build and tests need to be aligned
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E.g. https://github.com/kbase/file_cache_server/blob/develop/Dockerfile#L1 and maybe other placees
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I commented out the mypy check to allow the tests to run. Let me know if you know how to fix 945b204
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my experience mypy isn't worth the trouble as long as you have reasonable tests. I like what it's trying to do but it seems too clunky (although I haven't tried it recently, maybe it's better now)