From 0d62e7ae358635c13340a388805130fd11c45beb Mon Sep 17 00:00:00 2001 From: jeremy4040 Date: Mon, 27 May 2024 10:08:49 +0530 Subject: [PATCH] Codeql build change --- .github/workflows/codeql.yml | 10 +++++----- buildscript.sh | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 buildscript.sh diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index df705353..abfb6e03 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -55,8 +55,8 @@ jobs: # 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@v2 + # - name: Autobuild + # uses: github/codeql-action/autobuild@v2 # ℹī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -64,9 +64,9 @@ jobs: # If the Autobuild fails above, remove it and uncomment the following three lines. # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. - # - run: | - # echo "Run, Build Application using script" - # ./location_of_script_within_repo/buildscript.sh + - run: | + echo "Run, Build Application using script" + ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v2 diff --git a/buildscript.sh b/buildscript.sh new file mode 100644 index 00000000..85f99e23 --- /dev/null +++ b/buildscript.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +# Exit immediately if a command exits with a non-zero status. +set -e + +echo "Setting up Go environment" + +# Set the Go version. Adjust this to match the version you need. +GO_VERSION="1.19" + +# Download and install the specified Go version +echo "Installing Go ${GO_VERSION}" +curl -sSL https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz -o go${GO_VERSION}.linux-amd64.tar.gz +tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz +export PATH="/usr/local/go/bin:$PATH" + +# Verify Go installation +go version + +# Navigate to the repository root. Adjust if your project structure is different. +cd "$(dirname "$0")/.." + +echo "Installing dependencies" +# Install Go modules +go mod download + +echo "Building the project" +# Build the project. Adjust the build command if needed. +go build ./... + +echo "Running tests" +# Run tests +go test ./... + +echo "Build and tests completed successfully" +