Skip to content

Commit

Permalink
Merge branch '52-ci-check-that-all-labs-builds-without-any-warnings' …
Browse files Browse the repository at this point in the history
…into 'main'

CI: check that all labs builds without any warnings

Closes #52

See merge request feng/training/labs_solar_system!27
  • Loading branch information
leogermond committed Nov 17, 2023
2 parents 6e1c174 + cd2c1da commit 29f9362
Show file tree
Hide file tree
Showing 23 changed files with 167 additions and 61 deletions.
4 changes: 3 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@ sphinx:
paths:
- doc/_build/html/*

solutions:
check_builds:
services:
- image:ada-trainings
stage: build
script:
- mkdir -p alire/cache/
- cp -r $HOME/mage_*/alire/cache/dependencies alire/cache
- cp -r $HOME/mage_* alire/cache/dependencies
- export ADAFLAGS="-Werror"
- make build_solutions
- make build_problems

check_templates:
services:
Expand Down
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ generate_subprogram_contracts: $(template_subprogram_contracts)
adacut -m answer $$f > src/adv_270_subprogram_contracts/answers/$$(basename $$f); \
done

build_problems:
set -e; \
for lab in "Array_Types" "Record_Types" "Subprograms" "Packages" "Private_Types" "Access_Types" \
"Exceptions" "Interfacing_With_C" "Tasking_Protected_Objects" "Subprogram_Contracts"; do \
echo $$lab; \
Mode=Problem Lab="$$lab" alr build; \
done

build_solutions:
set -e; \
for lab in "Array_Types" "Record_Types" "Subprograms" "Packages" "Private_Types" "Access_Types" \
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ will select a new main file, which contains a solution for each lab.
Warning: After having changed the "Mode" variable, you may need to recompile the project by force,
by cleaning it.

All solutions should run out of the box, if they don't it is a bug, feel free to open a ticket.
All solutions and problems should run out of the box, if they don't it is a bug, feel free to open
a ticket.

## Known issues

Expand Down
11 changes: 4 additions & 7 deletions src/000_getting_started/src/getting_started_main.adb
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ procedure Getting_Started_Main is
begin
Window :=
Create_Window
(Width => Integer (Width),
Height => Integer (Height),
Name => "Bouncing ball");
(Width => Integer (Width), Height => Integer (Height),
Name => "Bouncing ball");
Canvas := Get_Canvas (Window);

Next := Clock + Period;
Expand All @@ -65,10 +64,8 @@ begin
Y := Y + Speed_Y;

Draw_Sphere
(Canvas => Canvas,
Position => (X, Y, 0.0),
Radius => Ball_Radius,
Color => Red);
(Canvas => Canvas, Position => (X, Y, 0.0), Radius => Ball_Radius,
Color => Red);

Handle_Events (Window);

Expand Down
9 changes: 9 additions & 0 deletions src/050_array_types/src/array_types_main.adb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ with Ada.Real_Time; use Ada.Real_Time;
with Mage; use Mage;
with Mage.Draw; use Mage.Draw;
with Mage.Event; use Mage.Event;

-- TODO: Remove these two lines once Cos and Sin are used
pragma Warnings (Off,
"no entities of ""Float_Maths"" are referenced");
pragma Warnings (Off,
"use clause for package ""Float_Maths"" has no effect");
with Float_Maths; use Float_Maths;

procedure Array_Types_Main is
Expand Down Expand Up @@ -54,6 +60,9 @@ procedure Array_Types_Main is
-- reference to the application window
Window : Window_ID;

-- TODO: Remove once you are drawing on the screen
pragma Warnings (Off,
"variable ""Canvas"" is assigned but never read");
-- reference to the graphical canvas associated with the application window
Canvas : Canvas_ID;

Expand Down
13 changes: 13 additions & 0 deletions src/050_array_types/template/array_types_main.adb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ with Ada.Real_Time; use Ada.Real_Time;
with Mage; use Mage;
with Mage.Draw; use Mage.Draw;
with Mage.Event; use Mage.Event;
--$ begin question

-- TODO: Remove these two lines once Cos and Sin are used
pragma Warnings (Off,
"no entities of ""Float_Maths"" are referenced");
pragma Warnings (Off,
"use clause for package ""Float_Maths"" has no effect");
--$ end question
with Float_Maths; use Float_Maths;

procedure Array_Types_Main is
Expand Down Expand Up @@ -66,6 +74,11 @@ procedure Array_Types_Main is
-- reference to the application window
Window : Window_ID;

--$ begin question
-- TODO: Remove once you are drawing on the screen
pragma Warnings (Off,
"variable ""Canvas"" is assigned but never read");
--$ end question
-- reference to the graphical canvas associated with the application window
Canvas : Canvas_ID;

Expand Down
3 changes: 2 additions & 1 deletion src/060_record_types/answers/record_types_main.adb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ procedure Record_Types_Main is
-- that rotate
subtype Rotating_Bodies_T is Bodies_Enum_T range Earth .. Satellite;

-- define a type Body_T to store every information about a body
-- replace the definition of Body_T by a type that stores every information
-- about a body:
-- X, Y, Distance, Speed, Angle, Color type is RGBA_T, Radius
type Body_T (Visible : Boolean := True) is record
X : Float;
Expand Down
17 changes: 16 additions & 1 deletion src/060_record_types/src/record_types_main.adb
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,23 @@ with Ada.Real_Time; use Ada.Real_Time;
with Mage; use Mage;
with Mage.Draw; use Mage.Draw;
with Mage.Event; use Mage.Event;

-- TODO: Remove once Cos and Sin are used
pragma Warnings (Off,
"no entities of ""Float_Maths"" are referenced");
pragma Warnings (Off,
"use clause for package ""Float_Maths"" has no effect");
with Float_Maths; use Float_Maths;

procedure Record_Types_Main is

-- TODO: Remove once lab is done
pragma Warnings (Off,
"not referenced");
pragma Warnings (Off,
"never read and never assigned");
pragma Warnings (Off, "assigned but never read");

-- define type Bodies_Enum_T as an enumeration of Sun, Earth, Moon,
-- and Satellite
type Bodies_Enum_T is (Sun, Earth, Moon, Satellite);
Expand All @@ -34,8 +47,10 @@ procedure Record_Types_Main is
-- that rotate
subtype Rotating_Bodies_T is Bodies_Enum_T range Earth .. Satellite;

-- define a type Body_T to store every information about a body
-- replace the definition of Body_T by a type that stores every information
-- about a body:
-- X, Y, Distance, Speed, Angle, Color type is RGBA_T, Radius
subtype Body_T is Integer; -- TODO: Replace by record type

-- define type Bodies_Array_T as an array of Body_T indexed by bodies
type Bodies_Array_T is array (Bodies_Enum_T) of Body_T;
Expand Down
22 changes: 21 additions & 1 deletion src/060_record_types/template/record_types_main.adb
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,26 @@ with Ada.Real_Time; use Ada.Real_Time;
with Mage; use Mage;
with Mage.Draw; use Mage.Draw;
with Mage.Event; use Mage.Event;
--$ begin question

-- TODO: Remove once Cos and Sin are used
pragma Warnings (Off,
"no entities of ""Float_Maths"" are referenced");
pragma Warnings (Off,
"use clause for package ""Float_Maths"" has no effect");
--$ end question
with Float_Maths; use Float_Maths;

procedure Record_Types_Main is
--$ begin question

-- TODO: Remove once lab is done
pragma Warnings (Off,
"not referenced");
pragma Warnings (Off,
"never read and never assigned");
pragma Warnings (Off, "assigned but never read");
--$ end question

-- define type Bodies_Enum_T as an enumeration of Sun, Earth, Moon,
-- and Satellite
Expand All @@ -34,8 +51,11 @@ procedure Record_Types_Main is
-- that rotate
subtype Rotating_Bodies_T is Bodies_Enum_T range Earth .. Satellite;

-- define a type Body_T to store every information about a body
-- replace the definition of Body_T by a type that stores every information
-- about a body:
-- X, Y, Distance, Speed, Angle, Color type is RGBA_T, Radius
--$ line question
subtype Body_T is Integer; -- TODO: Replace by record type
--$ begin answer
type Body_T (Visible : Boolean := True) is record
X : Float;
Expand Down
11 changes: 0 additions & 11 deletions src/070_subprograms/answers/subprograms_main.adb
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ procedure Subprograms_Main is

-- implement a function to compute the X coordinate
-- x of the reference + distance * cos(angle)
function Compute_X
(Body_To_Move : Body_T;
Turns_Around : Body_T) return Float;

function Compute_X
(Body_To_Move : Body_T;
Turns_Around : Body_T) return Float
Expand All @@ -80,9 +76,6 @@ procedure Subprograms_Main is

-- implement a function to compute the Y coordinate
-- y of the reference + distance * sin(angle)
function Compute_Y
(Body_To_Move : Body_T;
Turns_Around : Body_T) return Float;

function Compute_Y
(Body_To_Move : Body_T;
Expand All @@ -93,8 +86,6 @@ procedure Subprograms_Main is
end Compute_Y;

-- move a given body over one time step
procedure Move
(Bodies : in out Bodies_Array_T; Body_To_Move_Index : Bodies_Enum_T);

procedure Move
(Bodies : in out Bodies_Array_T; Body_To_Move_Index : Bodies_Enum_T) is
Expand All @@ -110,8 +101,6 @@ procedure Subprograms_Main is
Body_To_Move.Angle := Body_To_Move.Angle + Body_To_Move.Speed;
end Move;

procedure Draw_Body (Object : Body_T; Canvas : Canvas_ID);

procedure Draw_Body (Object : Body_T; Canvas : Canvas_ID) is
begin
Draw_Sphere
Expand Down
19 changes: 9 additions & 10 deletions src/070_subprograms/src/subprograms_main.adb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ with Mage.Event; use Mage.Event;
with Float_Maths; use Float_Maths;

procedure Subprograms_Main is
-- TODO: Remove once subprograms are implemented
pragma Warnings (Off, "not referenced");

-- define type Bodies_Enum_T and Rotating_Bodies_T
type Bodies_Enum_T is (Sun, Earth, Moon, Satellite, Comet);
Expand Down Expand Up @@ -64,12 +66,10 @@ procedure Subprograms_Main is
-- reference to the graphical canvas associated with the application window
Canvas : Canvas_ID;

-- TODO: Remove once function is referenced
pragma Warnings (Off, "function ""Compute_X"" is not referenced");
-- implement a function to compute the X coordinate
-- x of the reference + distance * cos(angle)
function Compute_X
(Body_To_Move : Body_T;
Turns_Around : Body_T) return Float;

function Compute_X
(Body_To_Move : Body_T;
Turns_Around : Body_T) return Float
Expand All @@ -80,15 +80,14 @@ procedure Subprograms_Main is

-- implement a function to compute the Y coordinate
-- y of the reference + distance * sin(angle)
function Compute_Y
(Body_To_Move : Body_T;
Turns_Around : Body_T) return Float;


-- move a given body over one time step
procedure Move
(Bodies : in out Bodies_Array_T; Body_To_Move_Index : Bodies_Enum_T);

procedure Move
(Bodies : in out Bodies_Array_T; Body_To_Move_Index : Bodies_Enum_T) is
begin
null;
end Move;

-- procedure Draw_Body takes 2 parameters of your choice:
-- it needs something to draw, and something to draw it on
Expand Down
29 changes: 15 additions & 14 deletions src/070_subprograms/template/subprograms_main.adb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ with Mage.Event; use Mage.Event;
with Float_Maths; use Float_Maths;

procedure Subprograms_Main is
--$ begin question
-- TODO: Remove once subprograms are implemented
pragma Warnings (Off, "not referenced");
--$ end question

-- define type Bodies_Enum_T and Rotating_Bodies_T
type Bodies_Enum_T is (Sun, Earth, Moon, Satellite, Comet);
Expand Down Expand Up @@ -64,12 +68,12 @@ procedure Subprograms_Main is
-- reference to the graphical canvas associated with the application window
Canvas : Canvas_ID;

--$ begin question
-- TODO: Remove once function is referenced
pragma Warnings (Off, "function ""Compute_X"" is not referenced");
--$ end question
-- implement a function to compute the X coordinate
-- x of the reference + distance * cos(angle)
function Compute_X
(Body_To_Move : Body_T;
Turns_Around : Body_T) return Float;

function Compute_X
(Body_To_Move : Body_T;
Turns_Around : Body_T) return Float
Expand All @@ -83,9 +87,6 @@ procedure Subprograms_Main is

-- implement a function to compute the Y coordinate
-- y of the reference + distance * sin(angle)
function Compute_Y
(Body_To_Move : Body_T;
Turns_Around : Body_T) return Float;

--$ begin answer
function Compute_Y
Expand All @@ -95,35 +96,35 @@ procedure Subprograms_Main is
begin
return Turns_Around.Y + Body_To_Move.Distance * Sin (Body_To_Move.Angle);
end Compute_Y;
--$ end answer

--$ end answer
-- move a given body over one time step
procedure Move
(Bodies : in out Bodies_Array_T; Body_To_Move_Index : Bodies_Enum_T);

--$ begin answer
procedure Move
(Bodies : in out Bodies_Array_T; Body_To_Move_Index : Bodies_Enum_T) is
--$ begin answer
Body_To_Move : Body_T renames Bodies (Body_To_Move_Index);
Turns_Around : constant Body_T := Bodies (Body_To_Move.Turns_Around);
--$ end answer
begin
--$ line question
null;
--$ begin answer
Body_To_Move.X :=
Compute_X (Body_To_Move, Turns_Around);

Body_To_Move.Y :=
Compute_Y (Body_To_Move, Turns_Around);

Body_To_Move.Angle := Body_To_Move.Angle + Body_To_Move.Speed;
--$ end answer
end Move;
--$ end answer

--$ begin question
-- procedure Draw_Body takes 2 parameters of your choice:
-- it needs something to draw, and something to draw it on
--$ end question
--$ begin answer
procedure Draw_Body (Object : Body_T; Canvas : Canvas_ID);

procedure Draw_Body (Object : Body_T; Canvas : Canvas_ID) is
begin
Draw_Sphere
Expand Down
3 changes: 3 additions & 0 deletions src/230_interfacing_with_c/src/solar_system.adb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

package body Solar_System is

-- TODO: Remove once subprograms are implemented
pragma Warnings (Off, "not referenced");

function Get_Body
(B : Bodies_Enum_T;
Bodies : access Bodies_Array_T) return Body_Access_T
Expand Down
5 changes: 5 additions & 0 deletions src/230_interfacing_with_c/template/solar_system.adb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
-----------------------------------------------------------------------

package body Solar_System is
--$ begin question

-- TODO: Remove once subprograms are implemented
pragma Warnings (Off, "not referenced");
--$ end question

function Get_Body
(B : Bodies_Enum_T;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ package body Solar_System.Graphics is
Draw_Body (Obj, Canvas);
end if;
end loop;

end Draw_All;

end Solar_System.Graphics;
Loading

0 comments on commit 29f9362

Please sign in to comment.