diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..df3a9c2 --- /dev/null +++ b/.github/workflows/cd.yml @@ -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/ci@v0.3 + 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 }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6789679..16155fe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/ruby/test/templates/index.html.erb b/ruby/test/templates/index.html.erb index 79f32f9..114bb94 100644 --- a/ruby/test/templates/index.html.erb +++ b/ruby/test/templates/index.html.erb @@ -15,8 +15,8 @@

<%= title %>

- CI Pipeline ID <%= ENV["CI_PIPELINE_ID"] %> from branch <%= ENV["CI_COMMIT_BRANCH"] %>@<%= ENV["CI_PROJECT_NAMESPACE"] %>/<%= ENV["CI_PROJECT_NAME"] %>
- Git Commit Hash <%= ENV["CI_COMMIT_SHA"] %> (<%= ENV["CI_COMMIT_SHORT_SHA"] %>) + CI Pipeline ID <%= ENV["CI_PIPELINE_ID"] %> from branch <%= ENV["CI_COMMIT_BRANCH"] %>@<%= ENV["CI_PROJECT"] %>
+ Git Commit Hash <%= ENV["CI_COMMIT_SHA"] %>

Finished in <%= total_time_to_hms %>, <%= '%.2f tests/s' % (count / total_time) %>, <%= '%.2f assertions/s' % (assertions / total_time) %> diff --git a/ruby/test/test_helper.rb b/ruby/test/test_helper.rb index 95e30ce..a4b9a8b 100644 --- a/ruby/test/test_helper.rb +++ b/ruby/test/test_helper.rb @@ -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