<<xAct`xTras`;

First, we need a 4D manifold.

DefManifold[M,4,IndexRange[a,n]]

Since we will work with coordinates now, we need to define our chart, whose name will be ch, the coordinates are numerated as {0,1,2,3}, they will be t, x, y and z (notice that we need to add [ ] after each coordinate because they will be defined as scalar fields). Finally, the base vectors of the chart will be associated the colour purple (this allows to distinguish between different charts in case we define more than one).

DefChart[ch,M,{0,1,2,3},{t[],x[],y[],z[]},ChartColor->Purple]

We' ll define the perturbation parameter and all the required functions

DefConstantSymbol[ϵ](*Parameter of the expansion*)

DefScalarFunction[aa,PrintAs->"a"](*Scale factor*)

DefScalarFunction[α] (*time perturbation*)
DefScalarFunction[B1] (*spacetime perturbation*)
DefScalarFunction[B2] (*spacetime perturbation*)
DefScalarFunction[B3] (*spacetime perturbation*)
DefScalarFunction[C11] (*spatial perturbation*)
DefScalarFunction[C12] (*spatial perturbation*)
DefScalarFunction[C13] (*spatial perturbation*)
DefScalarFunction[C22] (*spatial perturbation*)
DefScalarFunction[C23] (*spatial perturbation*)
DefScalarFunction[C33] (*spatial perturbation*)

The metric will be the following matrix:

metricmatrix=aa[t[]]^2 ({{-1,0,0,0},{0,1,0,0},{0,0,1,0},{0,0,0,1}}+ϵ {{0,B1[t[],x[],y[],z[]],B2[],B3[]},{B1[t[],x[],y[],z[]],C11[],C12[],C13[]},{B2[],C12[],C22[],C23[]},{B3[],C13[],C23[],C33[]}});
metricmatrix//MatrixForm
detg=Series[Det[metricmatrix],{ϵ,0,1}]

(* I made only B1 dependent on time and the coordinates to save computation time, as the error (strange RicciScalarcd below) appears already with this configuration *)

We now define a tensor called metric whose components will be the array defined above:

metric=CTensor[metricmatrix,{-ch,-ch}];(*CTensor refers to a tensor in a basis*)

and we set this tensor to be the metric of our chart, with the corresponding covariant derivative cd

SetCMetric[metric,ch,SignatureOfMetric->{3,1,0}]
cd=CovDOfMetric[metric];

We can compute different objects:

(*Riemanncd=Series[Riemann[cd],{ϵ,0,1}]*)
(*Riccicd=Ricci[cd];*)
RicciScalarcd=Series[RicciScalar[cd],{ϵ,0,1}]
(*Einsteincd=Einstein[cd];*)

RicciScalar[cd]/.ϵ^b_/;b≥2->0//FullSimplify