Skip to content

Commit

Permalink
WIP: some more additions to the CI/CD configuration, and some fixes t…
Browse files Browse the repository at this point in the history
…o the things David noticed in his review.
  • Loading branch information
rhliang committed Nov 21, 2024
1 parent 916aecd commit eec1c92
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 6 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build the Ruby package

on:
release:
types: [published]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code from repo
uses: actions/checkout@v3

- name: Log into GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build devcontainer and build the package
uses: devcontainers/[email protected]
with:
imageName: ghcr.io/cfe-lab/gotoh_devcontainer
cacheFrom: ghcr.io/cfe-lab/gotoh_devcontainer
runCmd: cd /workspaces/gotoh/ruby && bash build_gem.bash
env: |
CFE_GOTOH_VERSION=${{ github.ref_name }}
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ jobs:
imageName: ghcr.io/cfe-lab/gotoh_devcontainer
cacheFrom: ghcr.io/cfe-lab/gotoh_devcontainer
runCmd: cd /workspaces/gotoh/ruby && rake test
env: |
CI=1
CI_COMMIT_REF=${{ github.ref_name }}
CI_COMMIT_SHA=${{ github.sha }}
CI_PIPELINE_ID=${{ github.run_id }}
CI_COMMIT_BRANCH=${{ github.ref_name }}
CI_PROJECT=${{ github.repository }}
- name: Upload coverage reports to Codecov with GitHub Action
uses: codecov/codecov-action@v5
Expand Down
4 changes: 2 additions & 2 deletions ruby/test/templates/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<h1>
<%= title %></h1>
<h3>
<small>CI Pipeline ID <%= ENV["CI_PIPELINE_ID"] %> from branch <%= ENV["CI_COMMIT_BRANCH"] %>@<%= ENV["CI_PROJECT_NAMESPACE"] %>/<%= ENV["CI_PROJECT_NAME"] %></small></br>
<small>Git Commit Hash <%= ENV["CI_COMMIT_SHA"] %> (<%= ENV["CI_COMMIT_SHORT_SHA"] %>)</small>
<small>CI Pipeline ID <%= ENV["CI_PIPELINE_ID"] %> from branch <%= ENV["CI_COMMIT_BRANCH"] %>@<%= ENV["CI_PROJECT"] %></small></br>
<small>Git Commit Hash <%= ENV["CI_COMMIT_SHA"] %></small>
</h3>
<p>
Finished in <%= total_time_to_hms %>, <%= '%.2f tests/s' % (count / total_time) %>, <%= '%.2f assertions/s' % (assertions / total_time) %>
Expand Down
9 changes: 5 additions & 4 deletions ruby/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
require 'minitest/autorun'
require 'minitest/reporters'

if ENV['CI_COMMIT_TAG']
run_id = ENV['CI_COMMIT_TAG']
elsif ENV["CI"]
run_id = "#{ENV['CI_PIPELINE_ID']}-#{ENV['CI_COMMIT_SHORT_SHA']}"
# if ENV['CI_COMMIT_REF']
# run_id = ENV['CI_COMMIT_REF']
# elsif ENV["CI"]
if ENV['CI_COMMIT_REF']
run_id = "#{ENV['CI_COMMIT_REF']} #{ENV['CI_PIPELINE_ID']}-#{ENV['CI_COMMIT_SHA']}"
else
run_id = "LOCALBUILD"
end
Expand Down

0 comments on commit eec1c92

Please sign in to comment.