default:
  image: gcc:latest

stages:
  - build
  - test
  - final

compile-job:
  stage: build
  script:
    - echo "Compiling the project..."
    - gcc -c main.c
    - gcc -c utils.c
    - gcc -o main main.o utils.o
  artifacts :
    paths:
      - utils.o

test-job:
  stage: test
  script:
    - echo "Running tests..."
    - gcc -c test_utils.c
    - gcc -c utils.c
    - gcc -o test_utils test_utils.o utils.o
    - ./test_utils
  dependencies:
    - compile-job

test-job-2:
  stage: test
  script:
    - echo "Running tests for test_commut..."
    - gcc -c test_commut.c
    - gcc -o test_commut test_commut.o utils.o  # Use utils.o from the artifact
    - ./test_commut
  dependencies:
    - compile-job  # Use the utils.o artifact from compile-job

final-job:
  stage: final  # Define the new final job in the final stage
  script:
    - echo "All done"  # Simple job script to indicate completion