Skip to content

Commit

Permalink
Added build.yml file
Browse files Browse the repository at this point in the history
  • Loading branch information
MuditJ committed Feb 5, 2024
1 parent c50cb82 commit 8eaf177
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build Pipeline

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest # You can choose a different operating system if needed

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Golang
uses: actions/setup-go@v2
with:
go-version: '1.18' # Change this to the version you need

- name: Install dependencies
run: npm install

- name: Build
run: npm run build # Adjust the build command based on your project

- name: Run tests
run: npm test # Adjust the test command based on your project
44 changes: 44 additions & 0 deletions scripts/build-code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#Script to build all the solutions for different days
import os, subprocess

def main():
#Go two directories up
#Get a list of all directories, sequentially go into them and run go build
current_dir = os.getcwd()
main_dir = os.path.join(current_dir,os.pardir)
os.chdir(main_dir)
directories = [d for d in os.listdir(main_dir) if os.path.isdir(os.path.join(main_dir, d))]
print(directories)
print('*' * 20)
for directory in directories:
current_dir = os.getcwd()
path = os.path.join(main_dir, directory)
all_files = os.listdir(os.getcwd())
go_files = [f for f in all_files if os.path.isfile(os.path.join(current_dir, f)) and f.endswith(".go")]
#Build these golang files
build_code()

def build_code():
#Build all the golang files in current directory
# Run 'go build' command to build Golang code
process = subprocess.Popen(['go', 'build'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
stdout, stderr = process.communicate()

# Display the output
print("Build Output:")
print(stdout)

# Display errors, if any
if stderr:
print("Build Errors:")
print(stderr)

# Check the exit code
if process.returncode == 0:
print("Build succeeded.")
else:
print("Build failed.")


if __name__ == "__main__":
main()

0 comments on commit 8eaf177

Please sign in to comment.