Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 28 additions & 13 deletions dashboard/builds.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h2>FHIR IG Builds</h2>
</div>
</body>
<script>

function quoteattr(s) { // from https://stackoverflow.com/a/9756789/318206
return ('' + s) /* Forces the conversion to string. */
.replace(/&/g, '&amp;') /* This MUST be the 1st replacement. */
Expand All @@ -40,14 +40,16 @@ <h2>FHIR IG Builds</h2>
timeFormatter = timeago(),
buildsTable = document.getElementById("builds");

fetch("https://build.fhir.org/ig/builds.json")
.then(r => r.json())
fetch("/ig/builds.json")
.then(r => r.ok ? r.json() : [])
.catch(() => [])
.then(renderBranches)
.then(fetchBuilds)
.then(renderBuilds);

fetch("https://build.fhir.org/ig/qas.json")
.then(r => r.json())
fetch("/ig/qas.json")
.then(r => r.ok ? r.json() : [])
.catch(() => [])
.then(r => r.map(qa => {
qa.date = new Date(qa.date)
qa.master = /\/master\//.test(qa.repo)
Expand All @@ -58,13 +60,19 @@ <h2>FHIR IG Builds</h2>
.then(renderQas);

function renderBranches(builds) {
if (!builds || !Array.isArray(builds)) {
builds = [];
}
state.branches = parseBranches(builds);
render(state);
return builds;
}


function renderBuilds(builds) {
if (!builds || !Array.isArray(builds)) {
builds = [];
}
state.builds = builds;
render(state);
}
Expand Down Expand Up @@ -94,10 +102,13 @@ <h2>FHIR IG Builds</h2>


function parseBranches(builds) {
if (!builds || !Array.isArray(builds)) {
return {};
}
const grouped = _.groupBy(builds.map(entry =>{
const splitEntry = entry.split('/');
const failure = splitEntry.includes('failure');

return {
org: splitEntry[0],
repo: splitEntry[1],
Expand Down Expand Up @@ -131,7 +142,9 @@ <h2>FHIR IG Builds</h2>
return Promise.all(builds
.filter(repo => /\/master|main\//.test(repo))
.map(repo =>
fetchPool("https://build.fhir.org/ig/"+repo.replace("#", "%23")).then(b => b.text())
fetchPool("/ig/"+repo.replace("#", "%23"))
.then(b => b.ok ? b.text() : "")
.catch(() => "")
.then(b => {
var date = b.match(/Coordinated Universal Time \((.*?)\)/),
version = b.match(/Definitions (\S+)/);
Expand All @@ -153,8 +166,10 @@ <h2>FHIR IG Builds</h2>
}

function renderQas(qas) {
state.qas = qas
;
if (!qas || !Array.isArray(qas)) {
qas = [];
}
state.qas = qas;
render(state);
}

Expand All @@ -176,7 +191,7 @@ <h2>FHIR IG Builds</h2>
})
}


function render({builds, qas}){
const sorter = (a, b) => {
if (a.repo < b.repo) {
Expand Down Expand Up @@ -245,7 +260,7 @@ <h2>FHIR IG Builds</h2>
<th>links</th>
</thead><tr>` + rows.map(({org, repo, date, version, success, debug, choices}) =>
`<td>
<a target="_blank" href="https://build.fhir.org/ig/${org}/${repo}" data-toggle="tooltip" title='${quoteattr(JSON.stringify(debug, null, 2))}'>
<a target="_blank" href="/ig/${org}/${repo}" data-toggle="tooltip" title='${quoteattr(JSON.stringify(debug, null, 2))}'>
${org} / <strong>${repo}</strong></a>
</td>
<td>${version}</td>
Expand All @@ -261,9 +276,9 @@ <h2>FHIR IG Builds</h2>
${choices.map(branch => `<a id="branch-${branchnum}" class="dropdown-item" onClick="rebuild(${branchnum++}, '${org}', '${repo}', '${branch.name}')">${branch.name + (branch.failing ? " [failing]" : "")}</a>`).join(`\n`)}
</div>
</div>
<a target="_blank" class="btn btn-primary btn-sm" href="https://build.fhir.org/ig/${org}/${repo}/branches/__default/${success ? "" : "failure/"}build.log">log</a>
<a target="_blank" class="btn btn-primary btn-sm" href="/ig/${org}/${repo}/branches/__default/${success ? "" : "failure/"}build.log">log</a>
<a target="_blank" class="btn btn-primary btn-sm" href="https://github.com/${org}/${repo}">gh</a>
<a target="_blank" class="btn btn-primary btn-sm" href="https://build.fhir.org/ig/${org}/${repo}/branches/__default/${success ? "" : "failure/output/"}qa.html">qa</a>
<a target="_blank" class="btn btn-primary btn-sm" href="/ig/${org}/${repo}/branches/__default/${success ? "" : "failure/output/"}qa.html">qa</a>
</td>`
).join(`</tr><tr>`)

Expand Down
21 changes: 15 additions & 6 deletions images/ci-build/publish-ig
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,22 @@ function finish_upload_keepalive {
}
trap finish_upload_keepalive EXIT

# Replace forward slashes with underscores for safe use in file paths
function encode_branch_name {
echo "$1" | sed 's/\//\_/g'
}

IG_ORG=$1
IG_REPO=$2
DEPLOY_TO_BRANCH=${3:-master}
FAILURE_FLAG=${4:-success}
IS_DEFAUT_BRANCH=${5:-nondefault}

# Encode the branch name for safe file path usage
DEPLOY_TO_BRANCH_ENCODED=$(encode_branch_name "$DEPLOY_TO_BRANCH")

echo "DEBUG: Received arguments: ORG=$IG_ORG REPO=$IG_REPO BRANCH=$DEPLOY_TO_BRANCH BRANCH_ENCODED=$DEPLOY_TO_BRANCH_ENCODED FAILURE=$FAILURE_FLAG DEFAULT=$IS_DEFAUT_BRANCH" >&2

TARGET="${RANDOM}_${IG_ORG}_${IG_REPO}"

mkdir -p ~/uploading/$TARGET
Expand All @@ -24,19 +33,19 @@ KEEPALIVE_PID=$!
tar xzf - && date --iso-8601 > ~/uploading/$TARGET/done.txt || false

if [ "$FAILURE_FLAG" == "failure" ]; then
mkdir -p ~/uploading/www/ig/$IG_ORG/$IG_REPO/branches/$DEPLOY_TO_BRANCH
rm -rf ~/uploading/www/ig/$IG_ORG/$IG_REPO/branches/$DEPLOY_TO_BRANCH/failure || true
mv ~/uploading/$TARGET/ ~/uploading/www/ig/$IG_ORG/$IG_REPO/branches/$DEPLOY_TO_BRANCH/failure
mkdir -p ~/uploading/www/ig/$IG_ORG/$IG_REPO/branches/$DEPLOY_TO_BRANCH_ENCODED
rm -rf ~/uploading/www/ig/$IG_ORG/$IG_REPO/branches/$DEPLOY_TO_BRANCH_ENCODED/failure || true
mv ~/uploading/$TARGET/ ~/uploading/www/ig/$IG_ORG/$IG_REPO/branches/$DEPLOY_TO_BRANCH_ENCODED/failure
else
mv ~/uploading/www/ig/$IG_ORG/$IG_REPO/branches/$DEPLOY_TO_BRANCH ~/uploading/branch.$TARGET.old || true
mv ~/uploading/www/ig/$IG_ORG/$IG_REPO/branches/$DEPLOY_TO_BRANCH_ENCODED ~/uploading/branch.$TARGET.old || true
mkdir -p ~/uploading/www/ig/$IG_ORG/$IG_REPO/branches/
mv ~/uploading/$TARGET/ ~/uploading/www/ig/$IG_ORG/$IG_REPO/branches/$DEPLOY_TO_BRANCH
mv ~/uploading/$TARGET/ ~/uploading/www/ig/$IG_ORG/$IG_REPO/branches/$DEPLOY_TO_BRANCH_ENCODED
rm -rf ~/uploading/branch.$TARGET.old || true
fi

if [ "$IS_DEFAUT_BRANCH" == "default" ]; then
rm -f ~/uploading/www/ig/$IG_ORG/$IG_REPO/branches/__default
ln -s ./$DEPLOY_TO_BRANCH ~/uploading/www/ig/$IG_ORG/$IG_REPO/branches/__default
ln -s ./$DEPLOY_TO_BRANCH_ENCODED ~/uploading/www/ig/$IG_ORG/$IG_REPO/branches/__default
fi

set +e
Expand Down
8 changes: 0 additions & 8 deletions images/ig-publisher/Gemfile

This file was deleted.

81 changes: 0 additions & 81 deletions images/ig-publisher/Gemfile.lock

This file was deleted.

3 changes: 1 addition & 2 deletions images/ig-publisher/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ docker build --target ci -t ghcr.io/fhir/ig-publisher-ci .
### Multiplatform build

```sh
docker buildx build --platform linux/arm64,linux/amd64 .
docker buildx build --platform linux/arm64,linux/amd64 .
```


### Usage

#### Local Development
Expand Down
40 changes: 0 additions & 40 deletions images/ig-publisher/ci-files/Dockerfile

This file was deleted.

Loading