Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
beaver
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
orus-io
beaver
Commits
cea065ef
Commit
cea065ef
authored
2 years ago
by
steeve.chailloux
Browse files
Options
Downloads
Patches
Plain Diff
hydrate built files
parent
96daba2f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
runner/main.go
+32
-34
32 additions, 34 deletions
runner/main.go
with
32 additions
and
34 deletions
runner/main.go
+
32
−
34
View file @
cea065ef
...
...
@@ -39,20 +39,27 @@
}
else
{
outputDir
=
r
.
config
.
Output
}
if
r
.
config
.
HasShas
()
{
preBuildDir
:=
filepath
.
Join
(
tmpDir
,
"pre-build"
)
if
err
:=
r
.
DoBuild
(
tmpDir
,
preBuildDir
);
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to do pre-build: %w"
,
err
)
}
if
err
:=
r
.
config
.
SetShas
(
preBuildDir
);
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to set SHAs: %w"
,
err
)
}
files
,
err
:=
ioutil
.
ReadDir
(
preBuildDir
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"cannot list directory: %s - %w"
,
preBuildDir
,
err
)
}
if
err
:=
cleanDir
(
outputDir
);
err
!=
nil
{
return
fmt
.
Errorf
(
"cannot clean dir: %s: %w"
,
outputDir
,
err
)
}
variables
,
err
:=
r
.
config
.
prepareVariables
(
true
)
preBuildDir
:=
filepath
.
Join
(
tmpDir
,
"pre-build"
)
if
err
:=
r
.
DoBuild
(
tmpDir
,
preBuildDir
);
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to do pre-build: %w"
,
err
)
}
if
err
:=
r
.
config
.
SetShas
(
preBuildDir
);
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to set SHAs: %w"
,
err
)
}
files
,
err
:=
ioutil
.
ReadDir
(
preBuildDir
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"cannot list directory: %s - %w"
,
preBuildDir
,
err
)
}
if
err
:=
CleanDir
(
outputDir
);
err
!=
nil
{
return
fmt
.
Errorf
(
"cannot clean dir: %s: %w"
,
outputDir
,
err
)
}
variables
,
err
:=
r
.
config
.
prepareVariables
(
true
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"cannot prepare variables: %w"
,
err
)
}
for
_
,
file
:=
range
files
{
inFilePath
:=
filepath
.
Join
(
preBuildDir
,
file
.
Name
())
outFilePath
:=
filepath
.
Join
(
outputDir
,
file
.
Name
())
outFile
,
err
:=
os
.
Create
(
outFilePath
)
if
err
!=
nil
{
...
...
@@ -58,3 +65,3 @@
if
err
!=
nil
{
return
fmt
.
Errorf
(
"cannot
prepare variables: %w"
,
err
)
return
fmt
.
Errorf
(
"cannot
open: %s - %w"
,
outFilePath
,
err
)
}
...
...
@@ -60,15 +67,7 @@
}
for
_
,
file
:=
range
files
{
inFilePath
:=
filepath
.
Join
(
preBuildDir
,
file
.
Name
())
outFilePath
:=
filepath
.
Join
(
outputDir
,
file
.
Name
())
outFile
,
err
:=
os
.
Create
(
outFilePath
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"cannot open: %s - %w"
,
outFilePath
,
err
)
}
defer
func
()
{
_
=
outFile
.
Close
()
}()
if
err
:=
hydrate
(
inFilePath
,
outFile
,
variables
);
err
!=
nil
{
return
fmt
.
Errorf
(
"cannot hidrate: %s - %w"
,
outFilePath
,
err
)
}
defer
func
()
{
_
=
outFile
.
Close
()
}()
if
err
:=
hydrate
(
inFilePath
,
outFile
,
variables
);
err
!=
nil
{
return
fmt
.
Errorf
(
"cannot hidrate: %s - %w"
,
outFilePath
,
err
)
}
...
...
@@ -74,3 +73,2 @@
}
return
nil
}
...
...
@@ -76,5 +74,5 @@
}
return
r
.
DoBuild
(
tmpDir
,
outputDir
)
return
nil
}
func
(
r
*
Runner
)
DoBuild
(
tmpDir
,
outputDir
string
)
error
{
...
...
@@ -191,7 +189,7 @@
if
_
,
err
:=
tmpFile
.
WriteString
(
strings
.
Join
(
stdOut
,
"
\n
"
));
err
!=
nil
{
return
fmt
.
Errorf
(
"cannot write full compiled file: %w"
,
err
)
}
if
err
:=
c
leanDir
(
outputDir
);
err
!=
nil
{
if
err
:=
C
leanDir
(
outputDir
);
err
!=
nil
{
return
fmt
.
Errorf
(
"cannot clean dir: %s: %w"
,
outputDir
,
err
)
}
if
_
,
err
:=
YamlSplit
(
outputDir
,
tmpFile
.
Name
());
err
!=
nil
{
...
...
@@ -201,7 +199,7 @@
return
nil
}
func
c
leanDir
(
directory
string
)
error
{
func
C
leanDir
(
directory
string
)
error
{
if
err
:=
os
.
RemoveAll
(
directory
);
err
!=
nil
{
return
fmt
.
Errorf
(
"cannot cleanup output directory: %w"
,
err
)
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment