Skip to content

Commit

Permalink
spdx headers (#231)
Browse files Browse the repository at this point in the history
Related to #47 
Adding pre-commit check for SPDX headers. 
Deprecates #185 


### API Changes
No API changes introduced
  • Loading branch information
broskoTT authored Nov 6, 2024
1 parent 718132f commit 1dc0ec7
Show file tree
Hide file tree
Showing 33 changed files with 181 additions and 57 deletions.
44 changes: 44 additions & 0 deletions .check-copyright-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
DEFAULT:
perform_check: yes # should the check be performed?
# Sections setting this to 'no' don't need to include any other options as they are ignored
# When a file is using a section with the option set to 'no', no checks are performed.

# what licenses (or license expressions) are allowed for files in this section
# when setting this option in a section, you need to list all the allowed licenses
allowed_licenses:
- Apache-2.0
license_for_new_files: Apache-2.0 # license to be used when inserting a new copyright notice
new_notice_c: | # notice for new C, CPP, H, HPP and LD files
/*
* SPDX-FileCopyrightText: (c) {years} Tenstorrent Inc.
*
* SPDX-License-Identifier: {license}
*/
new_notice_python: | # notice for new python files
# SPDX-FileCopyrightText: {years} Tenstorrent Inc.
# SPDX-License-Identifier: {license}
# comment lines matching:
# SPDX-FileCopyrightText: year[-year] Espressif Systems
# or
# SPDX-FileContributor: year[-year] Espressif Systems
# are replaced with this template prefixed with the correct comment notation (# or // or *) and SPDX- notation
espressif_copyright: '{years} Tenstorrent Inc.'

# You can create your own rules for files or group of files
# examples_and_unit_tests:
# include:
# - 'examples/'
# - 'components/**/test/**'
# - 'components/**/test_apps/**'
# - 'tools/test_apps/**'
# allowed_licenses:
# - Apache-2.0
# - Unlicense
# - CC0-1.0
# license_for_new_files: Unlicense OR CC0-1.0

# ignore: # You can also select ignoring files here
# perform_check: no # Don't check files from that block
# include:
# - example/file/path
19 changes: 2 additions & 17 deletions .github/workflows/on-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,5 @@ jobs:
timeout: 15

pre-commit:
name: Run Pre-commit Hooks and Propose Fixes
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history so 'origin/main' is available

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11

- name: Run Pre-commit and Fix Issues
uses: pre-commit/[email protected]
with:
extra_args: "--from-ref origin/main --to-ref HEAD"
secrets: inherit
uses: ./.github/workflows/pre-commit.yml
24 changes: 4 additions & 20 deletions .github/workflows/on-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ jobs:
with:
timeout: 15

pre-commit:
secrets: inherit
uses: ./.github/workflows/pre-commit.yml

build-tests:
secrets: inherit
strategy:
Expand Down Expand Up @@ -48,23 +52,3 @@ jobs:
arch: ${{ matrix.test-group.arch }}
card: ${{ matrix.test-group.card }}
timeout: ${{ matrix.test-group.timeout }}

pre-commit:
name: Run Pre-commit Hooks and Propose Fixes
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history so 'origin/main' is available
ref: ${{ github.head_ref }}

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11

- name: Run Pre-commit and Fix Issues
uses: pre-commit/[email protected]
with:
extra_args: "--from-ref origin/main --to-ref HEAD"
26 changes: 26 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Run Pre-commit Hooks
name: Run Pre-commit Hooks

on:
workflow_call:
workflow_dispatch:

jobs:
pre-commit:
name: Run Pre-commit Hooks
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history so 'origin/main' is available

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11

- name: Run Pre-commit and Fix Issues
uses: pre-commit/[email protected]
with:
extra_args: "--from-ref origin/main --to-ref HEAD"
7 changes: 6 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@ repos:
rev: v1.35.1
hooks:
- id: yamllint
exclude: ^(?!\.github/).* # Only include files in .github/
exclude: ^(?!\.github/).* # Only include files in .github/
- repo: https://github.com/espressif/check-copyright/
rev: v1.0.3
hooks:
- id: check-copyright
args: ['--config', '.check-copyright-config.yaml', "--ignore", ""]
7 changes: 6 additions & 1 deletion common/backtrace.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* SPDX-FileCopyrightText: (c) 2023 Tenstorrent Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once

#include <cxxabi.h>
Expand Down Expand Up @@ -81,4 +86,4 @@ inline void register_segfault_handler() {
exit(EXIT_FAILURE);
}
}
} // namespace tt::assert
} // namespace tt::assert
2 changes: 1 addition & 1 deletion common/gtest_initializer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ void initialize_gtest(int argc, char** argv) {
} else {
setenv("LOGGER_LEVEL", "Debug", overwrite_env);
}
}
}
2 changes: 1 addition & 1 deletion common/logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,4 +263,4 @@ static void log_trace_(LogTypeDevice type, std::string const& src_info, char con
#define log_trace(...) ((void)0)
#define log_debug(...) ((void)0)
#define log_profile(...) ((void)0)
#endif
#endif
7 changes: 6 additions & 1 deletion device/blackhole/blackhole_coordinate_manager.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* SPDX-FileCopyrightText: (c) 2023 Tenstorrent Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "blackhole_coordinate_manager.h"

std::set<std::size_t> BlackholeCoordinateManager::get_x_coordinates_to_harvest(std::size_t harvesting_mask) {
Expand All @@ -21,4 +26,4 @@ tt_translated_coords BlackholeCoordinateManager::to_translated_coords(tt_logical
tt_logical_coords BlackholeCoordinateManager::to_logical_coords(tt_translated_coords translated_coords) {
tt_virtual_coords virtual_coords = tt_virtual_coords(translated_coords.x, translated_coords.y);
return CoordinateManager::to_logical_coords(virtual_coords);
}
}
2 changes: 1 addition & 1 deletion device/blackhole/blackhole_coordinate_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ class BlackholeCoordinateManager : public CoordinateManager {

protected:
std::set<std::size_t> get_x_coordinates_to_harvest(std::size_t harvesting_mask) override;
};
};
7 changes: 6 additions & 1 deletion device/coordinate_manager.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* SPDX-FileCopyrightText: (c) 2023 Tenstorrent Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "device/coordinate_manager.h"
#include <memory>
#include "coordinate_manager.h"
Expand Down Expand Up @@ -184,4 +189,4 @@ std::unique_ptr<CoordinateManager> CoordinateManager::get_coordinate_manager(
}

throw std::runtime_error("Invalid architecture for creating coordinate manager");
}
}
2 changes: 1 addition & 1 deletion device/coordinate_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ class CoordinateManager {
const tt_xy_pair worker_grid_size;
const std::vector<tt_xy_pair>& workers;
const std::size_t harvesting_mask;
};
};
2 changes: 1 addition & 1 deletion device/driver_atomics.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ static inline __attribute__((always_inline)) void mfence() {
#error "Unsupported architecture"
#endif

} // namespace tt_driver_atomics
} // namespace tt_driver_atomics
2 changes: 1 addition & 1 deletion device/grayskull/grayskull_coordinate_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ class GrayskullCoordinateManager : public CoordinateManager {
public:
GrayskullCoordinateManager(const tt_xy_pair& worker_grid_size, const std::vector<tt_xy_pair>& workers, std::size_t harvesting_mask)
: CoordinateManager(worker_grid_size, workers, harvesting_mask) {}
};
};
5 changes: 5 additions & 0 deletions device/simulation/deprecated/tt_emulation_device.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* SPDX-FileCopyrightText: (c) 2023 Tenstorrent Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdexcept>
#include <cstring>

Expand Down
5 changes: 5 additions & 0 deletions device/simulation/deprecated/tt_emulation_stub.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* SPDX-FileCopyrightText: (c) 2023 Tenstorrent Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdexcept>
#include <cstring>

Expand Down
2 changes: 1 addition & 1 deletion device/simulation/deprecated/tt_versim_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,4 +320,4 @@ std::uint32_t tt_VersimDevice::get_num_host_channels(std::uint32_t device_id) {
std::uint32_t tt_VersimDevice::get_host_channel_size(std::uint32_t device_id, std::uint32_t channel) {
// Host buffers not allocated for Versim Devices
return 0;
}
}
2 changes: 1 addition & 1 deletion device/tt_io.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: (c) 2024 Tenstorrent Inc.
// SPDX-FileCopyrightText: (c) 2023 Tenstorrent Inc.
//
// SPDX-License-Identifier: Apache-2.0

Expand Down
2 changes: 1 addition & 1 deletion device/tt_xy_pair.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ struct tt_chip_translated_coords : public tt_cxy_pair {
tt_chip_translated_coords() : tt_cxy_pair() {}
tt_chip_translated_coords(std::size_t ichip, xy_pair pair) : tt_cxy_pair(ichip, pair) {}
tt_chip_translated_coords(std::size_t ichip, std::size_t x, std::size_t y) : tt_cxy_pair(ichip, x, y) {}
};
};
7 changes: 6 additions & 1 deletion device/wormhole/wormhole_coordinate_manager.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* SPDX-FileCopyrightText: (c) 2023 Tenstorrent Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "wormhole_coordinate_manager.h"

std::set<std::size_t> WormholeCoordinateManager::get_y_coordinates_to_harvest(std::size_t harvesting_mask) {
Expand All @@ -19,4 +24,4 @@ tt_translated_coords WormholeCoordinateManager::to_translated_coords(tt_logical_

tt_logical_coords WormholeCoordinateManager::to_logical_coords(tt_translated_coords translated_coords) {
return tt_logical_coords(translated_coords.x - translated_coordinate_start_x, translated_coords.y - translated_coordinate_start_y);
}
}
2 changes: 1 addition & 1 deletion src/firmware/riscv/wormhole/eth_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,4 @@ static_assert(sizeof(cmd_q_t) == CMD_Q_SIZE_BYTES);
constexpr uint32_t REQUEST_CMD_QUEUE_BASE = ETH_ROUTING_STRUCT_ADDR + 128;
constexpr uint32_t REQUEST_ROUTING_CMD_QUEUE_BASE = REQUEST_CMD_QUEUE_BASE + sizeof(remote_update_ptr_t) + sizeof(remote_update_ptr_t) + sizeof(cmd_counters_t);
constexpr uint32_t RESPONSE_CMD_QUEUE_BASE = REQUEST_CMD_QUEUE_BASE + 2*CMD_Q_SIZE_BYTES;
constexpr uint32_t RESPONSE_ROUTING_CMD_QUEUE_BASE = RESPONSE_CMD_QUEUE_BASE + sizeof(remote_update_ptr_t) + sizeof(remote_update_ptr_t) + sizeof(cmd_counters_t);
constexpr uint32_t RESPONSE_ROUTING_CMD_QUEUE_BASE = RESPONSE_CMD_QUEUE_BASE + sizeof(remote_update_ptr_t) + sizeof(remote_update_ptr_t) + sizeof(cmd_counters_t);
2 changes: 1 addition & 1 deletion tests/api/test_cluster_descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,4 @@ TEST(ApiClusterDescriptorTest, SeparateClusters) {
chip_id_t closest_mmio_chip = cluster_desc->get_closest_mmio_capable_chip(chip);
EXPECT_TRUE(chip_clusters.are_same_set(chip, closest_mmio_chip));
}
}
}
7 changes: 6 additions & 1 deletion tests/api/test_soc_descriptor_bh.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* SPDX-FileCopyrightText: (c) 2023 Tenstorrent Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "gtest/gtest.h"

#include "device/tt_soc_descriptor.h"
Expand Down Expand Up @@ -205,4 +210,4 @@ TEST(SocDescriptor, SocDescriptorBHVirtualEqualTranslated) {
}
}
}
}
}
5 changes: 5 additions & 0 deletions tests/api/test_soc_descriptor_gs.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* SPDX-FileCopyrightText: (c) 2023 Tenstorrent Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "gtest/gtest.h"

#include "device/tt_soc_descriptor.h"
Expand Down
5 changes: 5 additions & 0 deletions tests/api/test_soc_descriptor_wh.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* SPDX-FileCopyrightText: (c) 2023 Tenstorrent Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "gtest/gtest.h"

#include "device/tt_soc_descriptor.h"
Expand Down
2 changes: 1 addition & 1 deletion tests/blackhole/test_bh_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,4 @@ class BlackholeTestFixture : public ::testing::Test {

};

} // namespace tt::umd::test::utils
} // namespace tt::umd::test::utils
5 changes: 5 additions & 0 deletions tests/emulation/test_emulation_device.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* SPDX-FileCopyrightText: (c) 2023 Tenstorrent Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "gtest/gtest.h"
#include "device/tt_soc_descriptor.h"
#include "device/tt_device.h"
Expand Down
5 changes: 5 additions & 0 deletions tests/microbenchmark/test_rw_tensix.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* SPDX-FileCopyrightText: (c) 2023 Tenstorrent Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <iostream>

Expand Down
7 changes: 6 additions & 1 deletion tests/pcie/test_pcie_device.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* SPDX-FileCopyrightText: (c) 2023 Tenstorrent Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <gtest/gtest.h>
#include "fmt/xchar.h"
Expand Down Expand Up @@ -33,4 +38,4 @@ TEST(PcieDeviceTest, Numa) {
} else {
SUCCEED() << "No PCIe devices were enumerated";
}
}
}
5 changes: 5 additions & 0 deletions tests/test_utils/device_test_utils.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* SPDX-FileCopyrightText: (c) 2023 Tenstorrent Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once

#include <cstdint>
Expand Down
5 changes: 5 additions & 0 deletions tests/test_utils/soc_desc_test_utils.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* SPDX-FileCopyrightText: (c) 2023 Tenstorrent Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once

#include <cstdint>
Expand Down
Loading

0 comments on commit 1dc0ec7

Please sign in to comment.