refactor: move security at inception ls #5763
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Copyright 2022 Snyk Ltd. | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License. | |
| name: Build | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| jobs: | |
| lint: | |
| name: lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Prepare git | |
| run: | | |
| git config --global core.autocrlf false | |
| git config --global core.longpaths true | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: 'go.mod' | |
| - name: Setup tools (`make tools`) | |
| uses: ./.github/actions/setup-tools | |
| - name: Run go generate commands | |
| run: make generate | |
| - name: Verify generated files match committed versions | |
| run: git status --porcelain=v1 | tee /dev/stderr | wc -l | grep -qE '^ *0 *$' | |
| - name: Lint source code | |
| run: make lint | |
| unit-tests: | |
| name: unit tests | |
| needs: [lint] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Prepare git | |
| run: | | |
| git config --global core.autocrlf false | |
| git config --global core.longpaths true | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: 'go.mod' | |
| - name: Set up Snyk CLI | |
| uses: snyk/actions/setup@master | |
| - name: Setup tools (`make tools`) | |
| uses: ./.github/actions/setup-tools | |
| - name: Run tests | |
| env: | |
| DEEPROXY_API_URL: ${{secrets.DEEPROXY_API_URL}} | |
| SNYK_TOKEN: ${{secrets.SNYK_TOKEN }} | |
| run: | | |
| export PATH=$PWD/.bin/pact/bin:$PATH | |
| # this is required to be able to test the clipboard | |
| export DISPLAY=:99 | |
| sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & | |
| sudo apt-get install -y xsel xclip wl-clipboard | |
| make clean test | |
| integration-tests: | |
| name: integration-tests | |
| needs: [lint] | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| steps: | |
| - name: Prepare git | |
| run: | | |
| git config --global core.autocrlf false | |
| git config --global core.longpaths true | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: 'go.mod' | |
| - name: Setup tools (`make tools`) | |
| if: matrix.os != 'windows-latest' | |
| uses: ./.github/actions/setup-tools | |
| - name: Run integration & smoke tests with Pact | |
| if: matrix.os == 'ubuntu-latest' | |
| env: | |
| DEEPROXY_API_URL: ${{secrets.DEEPROXY_API_URL}} | |
| SNYK_TOKEN: ${{secrets.SNYK_TOKEN }} | |
| INTEG_TESTS: "true" | |
| SMOKE_TESTS: "true" | |
| run: | | |
| export PATH=$PWD/.bin/pact/bin:$PATH | |
| # this is required to be able to test the clipboard | |
| export DISPLAY=:99 | |
| sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & | |
| sudo apt-get install -y xsel xclip wl-clipboard | |
| make clean test | |
| - name: Run integration tests with Pact | |
| if: matrix.os == 'macos-latest' | |
| env: | |
| DEEPROXY_API_URL: ${{secrets.DEEPROXY_API_URL}} | |
| SNYK_TOKEN: ${{secrets.SNYK_TOKEN }} | |
| INTEG_TESTS: "true" | |
| SMOKE_TESTS: "true" | |
| run: | | |
| export PATH=$PWD/.bin/pact/bin:$PATH | |
| # this is required to be able to test the clipboard | |
| export DISPLAY=:99 | |
| sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & | |
| make clean test | |
| - name: Run integration tests without Pact | |
| if: matrix.os == 'windows-latest' | |
| env: | |
| DEEPROXY_API_URL: ${{secrets.DEEPROXY_API_URL}} | |
| SNYK_TOKEN: ${{secrets.SNYK_TOKEN }} | |
| INTEG_TESTS: "true" | |
| SMOKE_TESTS: "true" | |
| run: | | |
| make clean test | |
| proxy-test: | |
| name: proxy-test | |
| needs: [lint] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Run proxy tests | |
| env: | |
| SNYK_TOKEN: ${{secrets.SNYK_TOKEN }} | |
| run: | | |
| make clean proxy-test | |
| race-tests: | |
| name: race-test | |
| needs: [lint] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: 'go.mod' | |
| - name: Setup tools (`make tools`) | |
| uses: ./.github/actions/setup-tools | |
| - name: Run race tests | |
| env: | |
| SNYK_TOKEN: ${{secrets.SNYK_TOKEN }} | |
| run: | | |
| export PATH=$PWD/.bin/pact/bin:$PATH | |
| # this is required to be able to test the clipboard | |
| export DISPLAY=:99 | |
| sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & | |
| sudo apt-get install -y xsel xclip wl-clipboard | |
| make clean race-test | |
| update-licenses: | |
| name: update licenses | |
| needs: [unit-tests] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Prepare git | |
| run: | | |
| git config --global core.autocrlf false | |
| git config --global core.longpaths true | |
| - uses: actions/checkout@v4 | |
| with: | |
| repository: ${{ github.event.pull_request.head.repo.full_name }} | |
| ref: ${{ github.event.pull_request.head.ref }} | |
| token: ${{ secrets.HAMMERHEAD_GITHUB_PAT_SNYKLS }} | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: 'go.mod' | |
| - name: Setup tools (`make tools`) | |
| uses: ./.github/actions/setup-tools | |
| - name: update licenses | |
| run: | | |
| make license-update | |
| - name: commit license changes | |
| uses: EndBug/add-and-commit@v9 | |
| with: | |
| default_author: github_actor | |
| committer_name: Github Actions | |
| committer_email: [email protected] | |
| message: "docs: updated licenses" | |
| add: "licenses" | |
| push: true | |
| test-release: | |
| name: test-release | |
| needs: [lint, unit-tests] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # does an unshallow checkout with tags & branches | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: 'go.mod' | |
| - name: Setup tools (`make tools`) | |
| uses: ./.github/actions/setup-tools | |
| - name: Create License Report | |
| id: create_license_report | |
| run: | | |
| LICENSES=$(make licenses) | |
| echo 'LICENSES<<EOF' >> $GITHUB_OUTPUT | |
| echo $LICENSES >> $GITHUB_OUTPUT | |
| echo 'EOF' >> $GITHUB_OUTPUT | |
| echo $LICENSES | |
| - name: Do test release with goreleaser | |
| uses: goreleaser/goreleaser-action@v6 | |
| env: | |
| LICENSES: ${{ steps.create_license_report.outputs.LICENSES }} | |
| with: | |
| version: "v2.4.7" | |
| args: release --clean --snapshot | |
| - name: Output compiled licenses | |
| run: | | |
| chmod +x build/snyk-ls_linux_amd64_v1/snyk-ls | |
| build/snyk-ls_linux_amd64_v1/snyk-ls -licenses | |
| - name: Dry-run upload script | |
| env: | |
| AWS_REGION: ${{ secrets.AWS_REGION }} | |
| AWS_S3_BUCKET_NAME: ${{ secrets.AWS_S3_BUCKET_NAME }} | |
| run: | | |
| .github/upload-to-s3.sh --dryrun |