From c24428702f769c6a26bd58608d2ece35b2990613 Mon Sep 17 00:00:00 2001 From: Rayan Syed Date: Sun, 29 Mar 2026 00:17:01 -0400 Subject: [PATCH] problem3 pipeline --- ci_cd/.gitlab-ci.yml | 2 ++ ci_cd/problem3a.yml | 49 +++++++++++++++++++++++++++++++ ci_cd/problem3b.yml | 49 +++++++++++++++++++++++++++++++ tests/Makefile | 20 ++++++++++--- tests/testSequenceA.cpp | 65 +++++++++++++++++++++++++++++++++++++++++ tests/testSequenceB.cpp | 58 ++++++++++++++++++++++++++++++++++++ 6 files changed, 239 insertions(+), 4 deletions(-) create mode 100644 ci_cd/problem3a.yml create mode 100644 ci_cd/problem3b.yml create mode 100644 tests/testSequenceA.cpp create mode 100644 tests/testSequenceB.cpp diff --git a/ci_cd/.gitlab-ci.yml b/ci_cd/.gitlab-ci.yml index bc1c0c6..8f07847 100644 --- a/ci_cd/.gitlab-ci.yml +++ b/ci_cd/.gitlab-ci.yml @@ -5,6 +5,8 @@ stages: include: - local: 'ci_cd/problem2.yml' # Planar Subgraph + - local: 'ci_cd/problem3a.yml' # Sequencing Simple + - local: 'ci_cd/problem3b.yml' # Sequencing Complications default: timeout: 5m diff --git a/ci_cd/problem3a.yml b/ci_cd/problem3a.yml new file mode 100644 index 0000000..bb40659 --- /dev/null +++ b/ci_cd/problem3a.yml @@ -0,0 +1,49 @@ +prebuild_problem_3a: + stage: prebuild + script: + - | + # Check if source files exist + if [ ! -f "sequence.cpp" ]; then + echo "sequence.cpp does not exist"; + exit 1; + fi + - git clone https://agile.bu.edu/gitlab/configs/ec330/homeworks/homeworksix.git hw6 + artifacts: + paths: + - hw6/ + rules: + - if: '$CI_COMMIT_REF_NAME == "problem3a"' + tags: [c++-17] + +compile_problem_3a: + stage: compile + needs: + - job: prebuild_problem_3a + artifacts: true + script: + - ls -l hw6/tests/ + - if [ -f "impl/MaxPlanarSubgraph.cpp" ]; then cp impl/MaxPlanarSubgraph.cpp hw6/tests/impl/; fi + - cp sequence.cpp hw6/tests/ + - cd hw6/tests + - make problem3a + artifacts: + paths: + - hw6/ + rules: + - if: '$CI_COMMIT_REF_NAME == "problem3a"' + tags: [c++-17] + +exec_problem_3a: + stage: test + needs: + - job: compile_problem_3a + artifacts: true + script: + - cd hw6/tests + - ./problem3a + artifacts: + paths: + - hw6/ + rules: + - if: '$CI_COMMIT_REF_NAME == "problem3a"' + tags: [c++-17] diff --git a/ci_cd/problem3b.yml b/ci_cd/problem3b.yml new file mode 100644 index 0000000..24ae548 --- /dev/null +++ b/ci_cd/problem3b.yml @@ -0,0 +1,49 @@ +prebuild_problem_3b: + stage: prebuild + script: + - | + # Check if source files exist + if [ ! -f "sequence.cpp" ]; then + echo "sequence.cpp does not exist"; + exit 1; + fi + - git clone https://agile.bu.edu/gitlab/configs/ec330/homeworks/homeworksix.git hw6 + artifacts: + paths: + - hw6/ + rules: + - if: '$CI_COMMIT_REF_NAME == "problem3b"' + tags: [c++-17] + +compile_problem_3b: + stage: compile + needs: + - job: prebuild_problem_3b + artifacts: true + script: + - ls -l hw6/tests/ + - if [ -f "impl/MaxPlanarSubgraph.cpp" ]; then cp impl/MaxPlanarSubgraph.cpp hw6/tests/impl/; fi + - cp sequence.cpp hw6/tests/ + - cd hw6/tests + - make problem3b + artifacts: + paths: + - hw6/ + rules: + - if: '$CI_COMMIT_REF_NAME == "problem3b"' + tags: [c++-17] + +exec_problem_3b: + stage: test + needs: + - job: compile_problem_3b + artifacts: true + script: + - cd hw6/tests + - ./problem3b + artifacts: + paths: + - hw6/ + rules: + - if: '$CI_COMMIT_REF_NAME == "problem3b"' + tags: [c++-17] diff --git a/tests/Makefile b/tests/Makefile index 741e1a8..32c226d 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -6,23 +6,35 @@ CXXFLAGS = -std=c++17 # Source files PROBLEM2_SRCS = testMaxPlanarSubgraph.cpp impl/MaxPlanarSubgraph.cpp impl/Vertex.cpp -SRCS = $(PROBLEM2_SRCS) +PROBLEM3A_SRCS = testSequenceA.cpp sequence.cpp +PROBLEM3B_SRCS = testSequenceB.cpp sequence.cpp +SRCS = $(PROBLEM2_SRCS) $(PROBLEM3A_SRCS) $(PROBLEM3B_SRCS) # Object files PROBLEM2_OBJS = testMaxPlanarSubgraph.o impl/MaxPlanarSubgraph.o impl/Vertex.o -OBJS = $(PROBLEM2_OBJS) +PROBLEM3A_OBJS = testSequenceA.o sequence.o +PROBLEM3B_OBJS = testSequenceB.o sequence.o +OBJS = $(PROBLEM2_OBJS) $(PROBLEM3A_OBJS) $(PROBLEM3B_OBJS) # Executable name PROBLEM2_EXEC = problem2 -EXECS = $(PROBLEM2_EXEC) +PROBLEM3A_EXEC = problem3a +PROBLEM3B_EXEC = problem3b +EXECS = $(PROBLEM2_EXEC) $(PROBLEM3A_EXEC) $(PROBLEM3B_EXEC) # Default target to build the executable -all: $(PROBLEM2_EXEC) +all: $(PROBLEM2_EXEC) $(PROBLEM3A_EXEC) $(PROBLEM3B_EXEC) # Rule to build the executable from object files $(PROBLEM2_EXEC): $(PROBLEM2_OBJS) Makefile $(CXX) $(CXXFLAGS) -o $(PROBLEM2_EXEC) $(PROBLEM2_OBJS) +$(PROBLEM3A_EXEC): $(PROBLEM3A_OBJS) Makefile + $(CXX) $(CXXFLAGS) -o $(PROBLEM3A_EXEC) $(PROBLEM3A_OBJS) + +$(PROBLEM3B_EXEC): $(PROBLEM3B_OBJS) Makefile + $(CXX) $(CXXFLAGS) -o $(PROBLEM3B_EXEC) $(PROBLEM3B_OBJS) + # Rules to build object files from source files %.o: %.cpp Makefile $(CXX) $(CXXFLAGS) -c $< -o $@ diff --git a/tests/testSequenceA.cpp b/tests/testSequenceA.cpp new file mode 100644 index 0000000..6048ca3 --- /dev/null +++ b/tests/testSequenceA.cpp @@ -0,0 +1,65 @@ +// +// Problem3a tests developed by Rayan w help from AI +// +#include +#include +#include +#include + +using namespace std; + +string sequence(const vector>& reads); + +// helper +bool failExample(const char* testName, const string& msg, string expected, string got) { + cerr << "[" << testName << " FAILED] " + << msg << ": expected " << expected + << ", got " << got << "\n"; + return false; +} + +bool test_0() { + const char* T = "sequence 3a"; + + { + vector> reads = {{ + {'A','B','C','D','E','F','G'} + }}; + + string got = sequence(reads); + string expected = "ABCDEFG"; + + if (got != expected) + return failExample(T, "single read", expected, got); + } + + { + vector> reads = {{ + {'A','B','C','D','E','F','G'}, + {'B','C','D','E','F','G','H'}, + {'C','D','E','F','G','H','I'} + }}; + + string got = sequence(reads); + string expected = "ABCDEFGHI"; + + if (got != expected) + return failExample(T, "simple overlap chain", expected, got); + } + + return true; +} + +int main() { + bool results[] = { test_0() }; + + bool allPassed = true; + for (size_t i = 0; i < std::size(results); i++) { + cout << "Test of problem " << to_string(i) << ": " + << (results[i] ? "passed" : "failed") << endl; + allPassed &= results[i]; + } + + if (allPassed) exit(0); + else exit(-1); +} \ No newline at end of file diff --git a/tests/testSequenceB.cpp b/tests/testSequenceB.cpp new file mode 100644 index 0000000..cbb1f05 --- /dev/null +++ b/tests/testSequenceB.cpp @@ -0,0 +1,58 @@ +// +// Problem3b tests developed by Rayan w help from AI +// +#include +#include +#include + +using namespace std; + +string sequence(vector reads); + +// helper +bool failExample(const char* testName, const string& msg, string expected, string got) { + cerr << "[" << testName << " FAILED] " + << msg << ": expected " << expected + << ", got " << got << "\n"; + return false; +} + +bool test_0() { + const char* T = "sequence 3b"; + + { + vector reads = {"ABCDEFG"}; + + string got = sequence(reads); + string expected = "ABCDEFG"; + + if (got != expected) + return failExample(T, "single read", expected, got); + } + + { + vector reads = {"ABC", "BCDE", "CDEFG"}; + + string got = sequence(reads); + string expected = "ABCDEFG"; + + if (got != expected) + return failExample(T, "simple overlap", expected, got); + } + + return true; +} + +int main() { + bool results[] = { test_0() }; + + bool allPassed = true; + for (size_t i = 0; i < std::size(results); i++) { + cout << "Test of problem " << to_string(i) << ": " + << (results[i] ? "passed" : "failed") << endl; + allPassed &= results[i]; + } + + if (allPassed) exit(0); + else exit(-1); +} \ No newline at end of file -- GitLab