Skip to content
Commits on Source (29)
stages:
- problem2
- problem3
- problem4
- extra
include:
- local: 'ci_cd/problem2.yml' # hw3, problem 1
- local: 'ci_cd/problem3.yml' # hw3, problem 3
- local: 'ci_cd/problem4.yml' # hw3, problem 4
- local: 'ci_cd/extra.yml' # hw3, extra credit
default:
timeout: 5m
prebuild_extra:
stage: extra
script:
- |
# Check if extra.cpp exists
if [ ! -f "extra.cpp" ]; then
echo "extra.cpp does not exist";
exit 1;
fi
rules:
- if: '$CI_COMMIT_REF_NAME == "extra"'
tags: [shell]
prebuild_extra_SKIP:
stage: extra
script:
- echo "SKIPPING extra credit checks because the branch name is not 'extra'"
rules:
- if: '$CI_COMMIT_REF_NAME != "extra"'
tags: [shell]
compile_extra:
stage: extra
script:
- echo "Compiling extra.cpp"
- git clone https://agile.bu.edu/gitlab/configs/ec327/hw-configs/hw3.git base_extra
- cp extra.cpp base_extra/tests
- cd base_extra/tests
- g++ -c extra.cpp
rules:
- if: '$CI_COMMIT_REF_NAME == "extra"'
tags: [c++-17]
lint_extra:
stage: extra
script:
- echo "Static code check of extra.cpp"
- cppcheck --check-config --enable=all --inconclusive --error-exitcode=1 extra.cpp
allow_failure: false
rules:
- if: '$CI_COMMIT_REF_NAME == "extra"'
tags: [cppcheck]
test_extra:
stage: extra
script:
- echo "Testing Extra Credit"
- git clone https://trachten-gitlab:${INTERNAL_HW_TESTS}@agile.bu.edu/gitlab/ec327/ec327-staff/hws/hw3-staff.git base_extra
- cp extra.cpp base_extra/tests
- cd base_extra/tests
- make extra
- ./extra $GITLAB_USER_LOGIN
rules:
- if: '$CI_COMMIT_REF_NAME == "extra"'
tags: [c++-17]
timeout: 15m
prebuild_problem_2:
stage: problem2
script:
- |
# Check if problem2.cpp exists
if [ ! -f "problem2.cpp" ]; then
echo "problem2.cpp does not exist";
exit 1;
fi
rules:
- if: '$CI_COMMIT_REF_NAME == "problem2"'
tags: [shell]
prebuild_problem_2_SKIP:
stage: problem2
script:
- echo "SKIPPING problem 2 checks because the branch name is not 'problem2'"
rules:
- if: '$CI_COMMIT_REF_NAME != "problem2"'
tags: [shell]
compile_problem_2:
stage: problem2
script:
- echo "Compiling problem2.cpp"
- g++ -c problem2.cpp
rules:
- if: '$CI_COMMIT_REF_NAME == "problem2"'
tags: [c++-17]
lint_problem_2:
stage: problem2
script:
- echo "Static code check of problem2.cpp"
- cppcheck --check-config --enable=all --inconclusive --error-exitcode=1 problem2.cpp
allow_failure: false
rules:
- if: '$CI_COMMIT_REF_NAME == "problem2"'
tags: [cppcheck]
test_problem_2:
stage: problem2
script:
- echo "Testing problem 2";
- git clone https://agile.bu.edu/gitlab/configs/ec327/hw-configs/hw3.git base_3
- cp problem2.cpp base_3/tests
- cd base_3/tests
- make problem2
- ./problem2
rules:
- if: '$CI_COMMIT_REF_NAME == "problem2"'
tags: [c++-17]
#internal_testing_problem_2:
# stage: problem2
# script:
# - echo "Internal testing problem 2";
# - git clone https://trachten-gitlab:${INTERNAL_HW_TESTS}@agile.bu.edu/gitlab/ec327/ec327-staff/hw-tests/homework-three-internal.git
# - cp -f problem2.cpp homework-three-internal/internal_tests/
# - cd homework-three-internal/internal_tests/
# - make internalTestProblem2
# - ./internalTestProblem2 > /dev/null 2>&1
# - RESULT=$(cat output.txt | tail -n 1)
# - curl "https://agile.bu.edu/ec327_scripts/bestScores.pl?key=$MAGIC_KEY&name=$GITLAB_USER_LOGIN&score=$RESULT"
# rules:
# - if: '$CI_COMMIT_REF_NAME == "problem2"'
# after_script:
# - cat homework-two-internal/internal_tests/output.txt
# tags: [c++-17]
# timeout: 12m
prebuild_problem_3:
stage: problem3
script:
- |
# Check if problem3.cpp exists
if [ ! -f "problem3.cpp" ]; then
echo "problem3.cpp does not exist";
exit 1;
fi
rules:
- if: '$CI_COMMIT_REF_NAME == "problem3"'
tags: [shell]
prebuild_problem_3_SKIP:
stage: problem3
script:
- echo "SKIPPING problem 3 checks because the branch name is not 'problem3'"
rules:
- if: '$CI_COMMIT_REF_NAME != "problem3"'
tags: [shell]
compile_problem_3:
stage: problem3
script:
- echo "Compiling problem3.cpp"
- git clone https://agile.bu.edu/gitlab/configs/ec327/hw-configs/hw3.git base_3
- cp problem3.cpp base_3/tests
- cd base_3/tests
- make problem3
rules:
- if: '$CI_COMMIT_REF_NAME == "problem3"'
tags: [c++-17]
lint_problem_3:
stage: problem3
script:
- echo "Static code check of problem3.cpp"
- cppcheck --check-config --enable=all --inconclusive --error-exitcode=1 problem3.cpp
allow_failure: false
rules:
- if: '$CI_COMMIT_REF_NAME == "problem3"'
tags: [cppcheck]
test_problem_3:
stage: problem3
script:
- echo "Testing problem 3";
- git clone https://agile.bu.edu/gitlab/configs/ec327/hw-configs/hw3.git base_3
- cp problem3.cpp base_3/tests
- cd base_3/tests
- make problem3
- ./problem3
rules:
- if: '$CI_COMMIT_REF_NAME == "problem3"'
tags: [c++-17]
prebuild_problem_4:
stage: problem4
script:
- |
# Check if problem4.cpp exists
if [ ! -f "problem4.cpp" ]; then
echo "problem4.cpp does not exist";
exit 1;
fi
rules:
- if: '$CI_COMMIT_REF_NAME == "problem4"'
tags: [shell]
prebuild_problem_4_SKIP:
stage: problem4
script:
- echo "SKIPPING problem 4 checks because the branch name is not 'problem4'"
rules:
- if: '$CI_COMMIT_REF_NAME != "problem4"'
tags: [shell]
compile_problem_4:
stage: problem4
script:
- echo "Compiling problem4.cpp"
- git clone https://agile.bu.edu/gitlab/configs/ec327/hw-configs/hw3.git base_4
- cp problem4.cpp base_4/tests
- cd base_4/tests
- make problem4
rules:
- if: '$CI_COMMIT_REF_NAME == "problem4"'
tags: [c++-17]
lint_problem_4:
stage: problem4
script:
- echo "Static code check of problem4.cpp"
- cppcheck --check-config --enable=all --inconclusive --error-exitcode=1 problem4.cpp
allow_failure: false
rules:
- if: '$CI_COMMIT_REF_NAME == "problem4"'
tags: [cppcheck]
test_problem_4:
stage: problem4
script:
- echo "Testing problem 4";
- git clone https://agile.bu.edu/gitlab/configs/ec327/hw-configs/hw3.git base_4
- cp problem4.cpp base_4/tests
- cd base_4/tests
- make problem4
- ./problem4
rules:
- if: '$CI_COMMIT_REF_NAME == "problem4"'
tags: [c++-17]
# Makefile, generated with support of ChatGPT
# Compiler and flags
CXX = g++
CXXFLAGS = -Wall -std=c++17
# Source files
PROBLEM2_SRCS = testProblem2.cpp problem2.cpp
PROBLEM3_SRCS = testProblem3.cpp problem3.cpp
PROBLEM4_SRCS = testProblem4.cpp problem4.cpp
SRCS = $(PROBLEM2_SRCS) $(PROBLEM3_SRCS) $(PROBLEM4_SRCS)
# Object files
PROBLEM2_OBJS = testProblem2.o problem2.o
PROBLEM3_OBJS = testProblem3.o problem3.o
PROBLEM4_OBJS = testProblem4.o problem4.o ttt_interface/ttt.o ttt_interface/HttpConnect.o
OBJS = $(PROBLEM2_OBJS) $(PROBLEM3_OBJS) $(PROBLEM4_OBJS)
# Executable names
PROBLEM2_EXEC = problem2
PROBLEM3_EXEC = problem3
PROBLEM4_EXEC = problem4
# Default target to build the executable
all: $(PROBLEM2_EXEC) $(PROBLEM3_EXEC) $(PROBLEM4_EXEC)
# Rule to build the executable from object files
$(PROBLEM2_EXEC): $(PROBLEM2_OBJS) Makefile
$(CXX) $(CXXFLAGS) -o $(PROBLEM2_EXEC) $(PROBLEM2_OBJS)
$(PROBLEM3_EXEC): $(PROBLEM3_OBJS) Makefile
$(CXX) $(CXXFLAGS) -o $(PROBLEM3_EXEC) $(PROBLEM3_OBJS)
$(PROBLEM4_EXEC): $(PROBLEM4_OBJS) Makefile
$(CXX) $(CXXFLAGS) -o $(PROBLEM4_EXEC) $(PROBLEM4_OBJS)
# Rules to build object files from source files, with dependency on the Common.h header
%.o: %.cpp %.h Makefile
$(CXX) $(CXXFLAGS) -c $< -o $@
# Clean target to remove compiled files
clean:
rm -f $(OBJS) $(EXEC)
//
// Created by Ari on 10/6/24.
//
#include <iostream>
#include <string>
using namespace std;
// prototype
int longestStreak(string gameBoard);
bool test_2a() {
string boardA = "x--------\n-x-------\n--x------\n";
string boardAp = "x--------\\n-x-------\\n--x------\\n";
if (longestStreak(boardA)!=3 && longestStreak(boardAp)!=3)
return false;
return true;
}
bool test_2b() {
string boardB = "xxxx----x\n-yyyyy--y\n";
string boardBp = "xxxx----x\\n-yyyyy--y\\n";
if (longestStreak(boardB)!=5 && longestStreak(boardBp)!=5)
return false;
return true;
}
int main() {
bool t2a = test_2a();
bool t2b = test_2b();
cout << "Test (a) of problem 2: " << (t2a ? "passed" : "failed") << endl;
cout << "Test (b) of problem 2: " << (t2b ? "passed" : "failed") << endl;
if (t2a && t2b) {
// all tests passed
exit(0);
}
else {
// at least one test was failed
exit (-1);
}
}
//
// Created by Ari on 10/6/24.
//
#include <iostream>
#include <string>
#include "../ttt_interface/ttt.h"
using namespace std;
// prototype
void randomNextMove(string board, SQUARE sideToMove, int& nextMoveRow, int& nextMoveCol);
bool test_3a() {
int nmr=-1, nmc=-1;
randomNextMove(
"---------\\n---------\\n---------\\n---------\\n---------\\n",
'y',
nmr,
nmc);
if (nmr==-1 || nmc==-1) // i.e., they were not updated
return false;
return true;
}
int main() {
bool t3a = test_3a();
cout << "Testing problem 3: " << (t3a ? "passed" : "failed") << endl;
if (t3a) {
// all tests passed
exit(0);
}
else {
// at least one test was failed
exit (-1);
}
}
\ No newline at end of file
//
// Created by Ari on 10/6/24.
//
#include <iostream>
#include <string>
#include "../ttt_interface/ttt.h"
using namespace std;
// prototype declaration
void playGame();
bool test_4a() {
// no tests for now
return true;
}
int main() {
bool t4a = test_4a();
cout << "Testing problem 4: " << (t4a ? "passed" : "failed") << endl;
if (t4a) {
// all tests passed
exit(0);
}
else {
// at least one test was failed
exit (-1);
}
}
\ No newline at end of file
../ttt_interface/
\ No newline at end of file
......@@ -111,7 +111,8 @@ SQUARE getBoardSquare(string board, int theRow, int theCol);
/**
* @param theGameCode The code of the Game in question.
* @return Who has won the game, or '-' if no one has won yet.
* @return Who has won the game, '*' if it was a tie, and
* '-' if no one has won yet.
*/
SQUARE getHasWon(GAME_CODE theGameCode);
......